about summary refs log tree commit diff
path: root/src/libcore/str
AgeCommit message (Collapse)AuthorLines
2015-07-13Add str::split_at_mutSimon Sapin-0/+15
2015-07-13Implement IndexMut for String and str.Simon Sapin-0/+64
... matching the existing Index impls. There is no reason not to if String implement DerefMut. The code removed in `src/librustc/middle/effect.rs` was added in #9750 to prevent things like `s[0] = 0x80` where `s: String`, but I belive became unnecessary when the Index(Mut) traits were introduced.
2015-07-04core: Use memcmp in is_prefix_of / is_suffix_ofUlrik Sverdrup-5/+4
The basic str equality in core::str calls memcmp, re-use the same function in StrSearcher's is_prefix_of, is_suffix_of.
2015-06-24StrSearcher: Explicitly separate the long and short casesUlrik Sverdrup-5/+11
This is needed to not drop performance, after the trait-based changes. Force separate versions of the next method to be generated for the short and long period cases.
2015-06-21StrSearcher: Use trait to specialize two way algorithm by caseUlrik Sverdrup-57/+133
Use a trait to be able to implement both the fast search that skips to each match, and the slower search that emits `Reject` intervals regularly. The latter is important for uses of `next_reject`.
2015-06-21StrSearcher: Specialize is_prefix_of/is_suffix_of for &strUlrik Sverdrup-17/+33
2015-06-21StrSearcher: Update substring search to use the Two Way algorithmUlrik Sverdrup-425/+466
To improve our substring search performance, revive the two way searcher and adapt it to the Pattern API. Fixes #25483, a performance bug: that particular case now completes faster in optimized rust than in ruby (but they share the same order of magnitude). Much thanks to @gereeter who helped me understand the reverse case better and wrote the comment explaining `next_back` in the code. I had quickcheck to fuzz test forward and reverse searching thoroughly. The two way searcher implements both forward and reverse search, but not double ended search. The forward and reverse parts of the two way searcher are completely independent. The two way searcher algorithm has very small, constant space overhead, requiring no dynamic allocation. Our implementation is relatively fast, especially due to the `byteset` addition to the algorithm, which speeds up many no-match cases. A bad case for the two way algorithm is: ``` let haystack = (0..10_000).map(|_| "dac").collect::<String>(); let needle = (0..100).map(|_| "bac").collect::<String>()); ``` For this particular case, two way is not much faster than the naive implementation it replaces.
2015-06-17std: Stabilize the `str_matches` featureAlex Crichton-2/+2
This commit stabilizes the `str::{matches, rmatches}` functions and iterators, but renames the unstable feature for the `str::{matches,rmatches}_indices` function to `str_match_indices` due to the comment present on the functions about the iterator's return value.
2015-06-17std: Remove two internal `str_internals` functionsAlex Crichton-4/+2
These were just exposed to be used elsewhere at some point, but neither is currently being used so just make them private again.
2015-06-17core: Split apart the global `core` featureAlex Crichton-5/+11
This commit shards the broad `core` feature of the libcore library into finer grained features. This split groups together similar APIs and enables tracking each API separately, giving a better sense of where each feature is within the stabilization process. A few minor APIs were deprecated along the way: * Iterator::reverse_in_place * marker::NoCopy
2015-06-16Auto merge of #26313 - steveklabnik:fix_str_docs, r=alexcrichtonbors-10/+10
Because these structures are created by a macro, the doc comments don't quite work: the leading /// isn't stripped. Instead, just use #[doc] so that they render correctly.
2015-06-15Fix up Split docsSteve Klabnik-10/+10
Because these structures are created by a macro, the doc comments don't quite work: the leading /// isn't stripped. Instead, just use #[doc] so that they render correctly.
2015-06-10Add str::split_atUlrik Sverdrup-0/+13
Implement RFC rust-lang/rfcs#1123 Add str method str::split_at(mid: usize) -> (&str, &str).
2015-05-11docs: Update FromStr documentationUlrik Sverdrup-2/+5
Fixes #25250
2015-05-09Convert #[lang="..."] to #[lang = "..."]Nick Hamann-1/+1
In my opinion this looks nicer, but also it matches the whitespace generally used for stability markers more closely.
2015-05-08core: impl AsRef<[u8]> for strSean McArthur-0/+9
2015-05-04Fix spelling errors in documentation.Joseph Crail-1/+1
2015-05-03Add #[inline(always)] to str::from_utf8_uncheckedJan Bujak-0/+1
Without the inline annotation this: str::from_utf8_unchecked( slice::from_raw_parts( ptr, len ) ) doesn't get inlined which can be pretty brutal performance-wise when used in an inner loop of a low level string manipulation method.
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-1/+0
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change]
2015-04-21std: Remove deprecated AsOsStr/Str/AsSlice traitsAlex Crichton-24/+0
Cleaning out more deprecated items
2015-04-21Auto merge of #24620 - pczarn:model-lexer-issues, r=cmrbors-2/+0
Fixes #15679 Fixes #15878 Fixes #15882 Closes #15883
2015-04-21Model lexer: Fix remaining issuesPiotr Czarnecki-2/+0
2015-04-20Make iterator struct docs more consistent.Steve Klabnik-13/+13
Fixes #24008.
2015-04-14Positive case of `len()` -> `is_empty()`Tamir Duberstein-2/+2
`s/(?<!\{ self)(?<=\.)len\(\) == 0/is_empty()/g`
2015-04-14rollup merge of #24377: apasel422/docsAlex Crichton-4/+4
Conflicts: src/libstd/net/ip.rs src/libstd/sys/unix/fs.rs src/libstd/sys/unix/mod.rs src/libstd/sys/windows/mod.rs
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-4/+4
2015-04-10std: Stabilize the Utf8Error typeAlex Crichton-22/+17
The meaning of each variant of this enum was somewhat ambiguous and it's uncler that we wouldn't even want to add more enumeration values in the future. As a result this error has been altered to instead become an opaque structure. Learning about the "first invalid byte index" is still an unstable feature, but the type itself is now stable.
2015-04-07std: Hide facade extension traits in docsAlex Crichton-0/+1
These traits are currently all just unstable parts of the facade which are implementation details for primitives further up the facade. This may make it more difficult to find what set of methods you get if only linking to libcore, but for now that's also unstable behavior. Closes #22025
2015-04-07Auto merge of #23952 - Kimundi:more_string_pattern, r=alexcrichtonbors-363/+587
This adds the missing methods and turns `str::pattern` in a user facing module, as per RFC. This also contains some big internal refactorings: - string iterator pairs are implemented with a central macro to reduce redundancy - Moved all tests from `coretest::str` into `collectionstest::str` and left a note to prevent the two sets of tests drifting apart further. See https://github.com/rust-lang/rust/issues/22477
2015-04-05Remove external iterator in CharIndices comment and the reference to the ↵Guillaume Gomez-2/+1
std::iter module
2015-04-05Added smoke tests for new methods.Marvin Löbel-10/+23
Fixed bug in existing StrSearcher impl
2015-04-05Refactored core::str::pattern to become a user-facing module and hide awayMarvin Löbel-13/+17
CharEq.
2015-04-05Re-added Clone impls to all str iteratorsMarvin Löbel-9/+82
2015-04-05Implemented remaining string pattern iterators.Marvin Löbel-344/+478
- Added missing reverse versions of methods - Added [r]matches() - Generated the string pattern iterators with a macro - Added where bounds to the methods returning reverse iterators for better error messages.
2015-04-01rollup merge of #23860: nikomatsakis/copy-requires-cloneAlex Crichton-1/+1
Conflicts: src/test/compile-fail/coherence-impls-copy.rs
2015-04-01rollup merge of #23945: pnkfelix/gate-u-negateAlex Crichton-1/+1
Feature-gate unsigned unary negate. Discussed in weekly meeting here: https://github.com/rust-lang/meeting-minutes/blob/master/weekly-meetings/2015-03-31.md#feature-gate--expr and also in the internals thread here: http://internals.rust-lang.org/t/forbid-unsigned-integer/752
2015-04-01fallout from feature-gating unary negation on unsigned integers.Felix S. Klock II-1/+1
2015-04-01rollup merge of #23951: alexcrichton/splitnAlex Crichton-11/+9
This commit is an implementation of [RFC 979][rfc] which changes the meaning of the count parameter to the `splitn` function on strings and slices. The parameter now means the number of items that are returned from the iterator, not the number of splits that are made. [rfc]: https://github.com/rust-lang/rfcs/pull/979 Closes #23911 [breaking-change]
2015-04-01std: Changing the meaning of the count to splitnAlex Crichton-11/+9
This commit is an implementation of [RFC 979][rfc] which changes the meaning of the count parameter to the `splitn` function on strings and slices. The parameter now means the number of items that are returned from the iterator, not the number of splits that are made. [rfc]: https://github.com/rust-lang/rfcs/pull/979 Closes #23911 [breaking-change]
2015-04-01Collect the definition of the `Error` trait into `libstd` for now. ThisNiko Matsakis-16/+0
sidesteps a coherence difficulty where `liballoc` had to prove that `&str: !Error`, which didn't involve any local types.
2015-04-01Fallout in public-facing and semi-public-facing libsNiko Matsakis-1/+1
2015-03-31std: Clean out #[deprecated] APIsAlex Crichton-141/+125
This commit cleans out a large amount of deprecated APIs from the standard library and some of the facade crates as well, updating all users in the compiler and in tests as it goes along.
2015-03-31Stabilize std::numAaron Turon-2/+2
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change]
2015-03-28Remove IteratorExtSteven Fackler-2/+2
All methods are inlined into Iterator with `Self: Sized` bounds to make sure Iterator is still object safe. [breaking-change]
2015-03-27rollup merge of #23741: alexcrichton/remove-int-uintAlex Crichton-1/+1
Conflicts: src/librustc/middle/ty.rs src/librustc_trans/trans/adt.rs src/librustc_typeck/check/mod.rs src/libserialize/json.rs src/test/run-pass/spawn-fn.rs
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-1/+1
Now that support has been removed, all lingering use cases are renamed.
2015-03-26Register new snapshotsAlex Crichton-88/+0
2015-03-25Rollup merge of #23664 - bluss:std-docs, r=steveklabnikManish Goregaokar-8/+7
Main motivation was to update docs for the removal or "demotion" of certain extension traits. The update to the slice docs was larger, since the text was largely outdated.
2015-03-24Test fixes and rebase conflicts, round 2Alex Crichton-0/+1
2015-03-24rollup merge of #23630: nrc/coerce-tidyAlex Crichton-1/+1
See notes on the first commit Closes #18601 r? @nikomatsakis cc @eddyb