about summary refs log tree commit diff
path: root/src/libstd/str.rs
AgeCommit message (Collapse)AuthorLines
2014-05-27auto merge of #14414 : richo/rust/features/nerf_unused_string_fns, ↵bors-113/+115
r=alexcrichton This should block on #14323
2014-05-27std: Rename strbuf operations to stringRicho Healey-28/+28
[breaking-change]
2014-05-27std: Remove String's to_ownedRicho Healey-81/+84
2014-05-26std: Remove String::from_owned_str as it's redundantRicho Healey-4/+3
[breaking-change]
2014-05-26Minor fixes to `std::str` docsP1start-11/+12
This tweaks the `std::str` docs to compensate for the recent shift from `~str` to `String`.
2014-05-24core: rename strbuf::StrBuf to string::StringRicho Healey-96/+96
[breaking-change]
2014-05-23auto merge of #14360 : alexcrichton/rust/remove-deprecated, r=kballardbors-2/+2
These have all been deprecated for awhile now, so it's likely time to start removing them.
2014-05-22libcore: Remove all uses of `~str` from `libcore`.Patrick Walton-81/+65
[breaking-change]
2014-05-22libstd: Remove all uses of `~str` from `libstd`Patrick Walton-164/+121
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-10/+12
2014-05-22Remove a slew of old deprecated functionsAlex Crichton-2/+2
2014-05-16auto merge of #14135 : gereeter/rust/two-way-search, r=brsonbors-0/+74
This changes the previously naive string searching algorithm to a two-way search like glibc, which should be faster on average while still maintaining worst case linear time complexity. This fixes #14107. Note that I don't think this should be merged yet, as this is the only approach to speeding up search I've tried - it's worth considering options like Boyer-Moore or adding a bad character shift table to this. However, the benchmarks look quite good so far: test str::bench::bench_contains_bad_naive ... bench: 290 ns/iter (+/- 12) from 1309 ns/iter (+/- 36) test str::bench::bench_contains_equal ... bench: 479 ns/iter (+/- 10) from 137 ns/iter (+/- 2) test str::bench::bench_contains_short_long ... bench: 2844 ns/iter (+/- 105) from 5473 ns/iter (+/- 14) test str::bench::bench_contains_short_short ... bench: 55 ns/iter (+/- 4) from 57 ns/iter (+/- 6) Except for the case specifically designed to be optimal for the naive case (`bench_contains_equal`), this gets as good or better performance as the previous code.
2014-05-15auto merge of #14213 : kballard/rust/str_from_utf8_result, r=cmrbors-7/+10
Change `str::from_utf8_owned()` and `StrBuf::from_utf8()` to return `Result`. This allows the vector to be recovered when it contains invalid UTF-8.
2014-05-15Add `IntoMaybeOwned` impl for `StrBuf` to ease conversion to `MaybeOwned`.Felix S. Klock II-0/+5
2014-05-14Change str::from_utf8_owned() to return ResultKevin Ballard-7/+10
This allows the original vector to be recovered in the event that it is not valid UTF-8. [breaking-change]
2014-05-14Added substring searching benchmarks.Jonathan S-0/+74
test str::bench::bench_contains_bad_naive ... bench: 1309 ns/iter (+/- 36) test str::bench::bench_contains_equal ... bench: 137 ns/iter (+/- 2) test str::bench::bench_contains_short_long ... bench: 5473 ns/iter (+/- 14) test str::bench::bench_contains_short_short ... bench: 57 ns/iter (+/- 6)
2014-05-13std: Rename str::Normalizations to str::DecompositionsFlorian Zeitz-16/+16
The Normalizations iterator has been renamed to Decompositions. It does not currently include all forms of Unicode normalization, but only encompasses decompositions. If implemented recomposition would likely be a separate iterator which works on the result of this one. [breaking-change]
2014-05-11core: Remove the cast moduleAlex Crichton-16/+16
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-08Handle breakage after libcore splitKevin Ballard-4/+5
API Changes: - &[T] and ~[T] no longer support the addition operator (+)
2014-05-08Clean up unused importsKevin Ballard-6/+5
2014-05-08Even more fallout, this time in std::strKevin Ballard-92/+85
- StrSlice.to_utf16() now returns a Vec<u8>. - Other miscellaneous fallout in std::str.
2014-05-07core: Inherit possible string functionalityAlex Crichton-1929/+90
This moves as much allocation as possible from teh std::str module into core::str. This includes essentially all non-allocating functionality, mostly iterators and slicing and such. This primarily splits the Str trait into only having the as_slice() method, adding a new StrAllocating trait to std::str which contains the relevant new allocation methods. This is a breaking change if any of the methods of "trait Str" were overriden. The old functionality can be restored by implementing both the Str and StrAllocating traits. [breaking-change]
2014-05-07auto merge of #13958 : pcwalton/rust/detilde, r=pcwaltonbors-3/+3
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. r? @brson or @alexcrichton or whoever
2014-05-07auto merge of #13914 : alexcrichton/rust/pile-o-rustdoc-fixes, r=brsonbors-1/+1
Lots of assorted things here and there, all the details are in the commits. Closes #11712
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-3/+3
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-03rustdoc: Migrate from sundown to hoedownAlex Crichton-1/+1
This primary fix brought on by this upgrade is the proper matching of the ``` and ~~~ doc blocks. This also moves hoedown to a git submodule rather than a bundled repository. Additionally, hoedown is stricter about code blocks, so this ended up fixing a lot of invalid code blocks (ending with " ```" instead of "```", or ending with "~~~~" instead of "~~~"). Closes #12776
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-50/+50
2014-05-01auto merge of #13877 : thestinger/rust/de-tilde-str-vec, r=alexcrichtonbors-10/+10
2014-05-01remove leftover obsolete string literalsDaniel Micay-10/+10
2014-04-28Deprecate the rev_iter pattern in all places where a DoubleEndedIterator is ↵Jonathan S-43/+41
provided (everywhere but treemap) This commit deprecates rev_iter, mut_rev_iter, move_rev_iter everywhere (except treemap) and also deprecates related functions like rsplit, rev_components, and rev_str_components. In every case, these functions can be replaced with the non-reversed form followed by a call to .rev(). To make this more concrete, a translation table for all functional changes necessary follows: * container.rev_iter() -> container.iter().rev() * container.mut_rev_iter() -> container.mut_iter().rev() * container.move_rev_iter() -> container.move_iter().rev() * sliceorstr.rsplit(sep) -> sliceorstr.split(sep).rev() * path.rev_components() -> path.components().rev() * path.rev_str_components() -> path.str_components().rev() In terms of the type system, this change also deprecates any specialized reversed iterator types (except in treemap), opting instead to use Rev directly if any type annotations are needed. However, since methods directly returning reversed iterators are now discouraged, the need for such annotations should be small. However, in those cases, the general pattern for conversion is to take whatever follows Rev in the original reversed name and surround it with Rev<>: * RevComponents<'a> -> Rev<Components<'a>> * RevStrComponents<'a> -> Rev<StrComponents<'a>> * RevItems<'a, T> -> Rev<Items<'a, T>> * etc. The reasoning behind this change is that it makes the standard API much simpler without reducing readability, performance, or power. The presence of functions such as rev_iter adds more boilerplate code to libraries (all of which simply call .iter().rev()), clutters up the documentation, and only helps code by saving two characters. Additionally, the numerous type synonyms that were used to make the type signatures look nice like RevItems add even more boilerplate and clutter up the docs even more. With this change, all that cruft goes away. [breaking-change]
2014-04-23auto merge of #13686 : alexcrichton/rust/issue-12224, r=nikomatsakisbors-50/+60
This alters the borrow checker's requirements on invoking closures from requiring an immutable borrow to requiring a unique immutable borrow. This means that it is illegal to invoke a closure through a `&` pointer because there is no guarantee that is not aliased. This does not mean that a closure is required to be in a mutable location, but rather a location which can be proven to be unique (often through a mutable pointer). For example, the following code is unsound and is no longer allowed: type Fn<'a> = ||:'a; fn call(f: |Fn|) { f(|| { f(|| {}) }); } fn main() { call(|a| { a(); }); } There is no replacement for this pattern. For all closures which are stored in structures, it was previously allowed to invoke the closure through `&self` but it now requires invocation through `&mut self`. The standard library has a good number of violations of this new rule, but the fixes will be separated into multiple breaking change commits. Closes #12224
2014-04-23std: Change CharEq to take `&mut self`Alex Crichton-50/+60
This is similar to the previous commits to allow invocation of a closure through a `&mut self` pointer because `&self` is disallowed. One of the primary implementors of the CharEq trait is a closure type, which would not work if the method continued to have `&self`. In addition to changing mutability of the `matches` method, this modifies the following methods from &CharEq to take a type which implements CharEq by value. * trim_chars * trim_left_chars * trim_right_chars Where these methods were previously invoked via s.trim_chars(&'a') it would now be invoked through s.trim_chars('a') [breaking-change]
2014-04-22auto merge of #13674 : pcwalton/rust/more-str-inlines, r=alexcrichtonbors-0/+4
Was killing performance of selector matching in Servo. r? @alexcrichton (or anyone)
2014-04-21str: Inline `only_ascii` in string iterators.Patrick Walton-0/+4
Was killing performance of selector matching in Servo.
2014-04-21Fix misspellings in comments.Joseph Crail-3/+3
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-130/+134
2014-04-18std: Make ~[T] no longer a growable vectorAlex Crichton-62/+31
This removes all resizability support for ~[T] vectors in preparation of DST. The only growable vector remaining is Vec<T>. In summary, the following methods from ~[T] and various functions were removed. Each method/function has an equivalent on the Vec type in std::vec unless otherwise stated. * slice::OwnedCloneableVector * slice::OwnedEqVector * slice::append * slice::append_one * slice::build (no replacement) * slice::bytes::push_bytes * slice::from_elem * slice::from_fn * slice::with_capacity * ~[T].capacity() * ~[T].clear() * ~[T].dedup() * ~[T].extend() * ~[T].grow() * ~[T].grow_fn() * ~[T].grow_set() * ~[T].insert() * ~[T].pop() * ~[T].push() * ~[T].push_all() * ~[T].push_all_move() * ~[T].remove() * ~[T].reserve() * ~[T].reserve_additional() * ~[T].reserve_exect() * ~[T].retain() * ~[T].set_len() * ~[T].shift() * ~[T].shrink_to_fit() * ~[T].swap_remove() * ~[T].truncate() * ~[T].unshift() * ~str.clear() * ~str.set_len() * ~str.truncate() Note that no other API changes were made. Existing apis that took or returned ~[T] continue to do so. [breaking-change]
2014-04-11Implement Char::encode_utf16Keegan McAllister-16/+3
And clean up encode_utf8 a bit.
2014-04-11libtest: rename `BenchHarness` to `Bencher`Liigo Zhuang-39/+39
Closes #12640
2014-04-10libstd: Implement `StrBuf`, a new string buffer type like `Vec`, andPatrick Walton-477/+82
port all code over to use it.
2014-04-08Register new snapshotsAlex Crichton-1/+1
2014-04-02Fix fallout of requiring uint indicesAlex Crichton-3/+3
2014-03-31std: Switch field privacy as necessaryAlex Crichton-24/+24
2014-03-30Rename `from_iterator` to `from_iter` for consistency.Brian Anderson-1/+1
2014-03-29auto merge of #13183 : erickt/rust/remove-list, r=alexcrichtonbors-1/+1
`collections::list::List` was decided in a [team meeting](https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-03-25) that it was unnecessary, so this PR removes it. Additionally, it removes an old and redundant purity test and fixes some warnings.
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-1/+1
Closes #2569
2014-03-28std and green: fix some warningsErick Tryzelaar-1/+1
2014-03-25Changed `iter::Extendable` and `iter::FromIterator` to take a `Iterator` by ↵Marvin Löbel-4/+4
value
2014-03-23auto merge of #13102 : huonw/rust/totaleq-deriving, r=thestingerbors-22/+5
std: remove the `equals` method from `TotalEq`. `TotalEq` is now just an assertion about the `Eq` impl of a type (i.e. `==` is a total equality if a type implements `TotalEq`) so the extra method is just confusing. Also, a new method magically appeared as a hack to allow deriving to assert that the contents of a struct/enum are also TotalEq, because the deriving infrastructure makes it very hard to do anything but create a trait method. (You didn't hear about this horrible work-around from me :(.)
2014-03-23std: remove the `equals` method from `TotalEq`.Huon Wilson-22/+5
`TotalEq` is now just an assertion about the `Eq` impl of a type (i.e. `==` is a total equality if a type implements `TotalEq`) so the extra method is just confusing. Also, a new method magically appeared as a hack to allow deriving to assert that the contents of a struct/enum are also TotalEq, because the deriving infrastructure makes it very hard to do anything but create a trait method. (You didn't hear about this horrible work-around from me :(.)