summary refs log tree commit diff
path: root/src/libcollections/string.rs
AgeCommit message (Collapse)AuthorLines
2017-01-25std: Stabilize APIs for the 1.16.0 releaseAlex Crichton-7/+2
This commit applies the stabilization/deprecations of the 1.16.0 release, as tracked by the rust-lang/rust issue tracker and the final-comment-period tag. The following APIs were stabilized: * `VecDeque::truncate` * `VecDeque::resize` * `String::insert_str` * `Duration::checked_{add,sub,div,mul}` * `str::replacen` * `SocketAddr::is_ipv{4,6}` * `IpAddr::is_ipv{4,6}` * `str::repeat` * `Vec::dedup_by` * `Vec::dedup_by_key` * `Result::unwrap_or_default` * `<*const T>::wrapping_offset` * `<*mut T>::wrapping_offset` * `CommandExt::creation_flags` (on Windows) * `File::set_permissions` * `String::split_off` The following APIs were deprecated * `EnumSet` - replaced with other ecosystem abstractions, long since unstable Closes #27788 Closes #35553 Closes #35774 Closes #36436 Closes #36949 Closes #37079 Closes #37087 Closes #37516 Closes #37827 Closes #37916 Closes #37966 Closes #38080
2017-01-14have RangeArgument return a Bound<&T> from each of its methodsdjzin-2/+11
2016-12-20run rustfmt on libcollections folderSrinivas Reddy Thatiparthy-7/+3
2016-12-12Auto merge of #38049 - frewsxcv:libunicode, r=alexcrichtonbors-2/+2
Rename 'librustc_unicode' crate to 'libstd_unicode'. Fixes https://github.com/rust-lang/rust/issues/26554.
2016-12-03Remove redundant assertion near is_char_boundary.Clar Charr-4/+0
2016-11-30Add String::split_off.Clar Charr-0/+33
2016-11-30Rename 'librustc_unicode' crate to 'libstd_unicode'.Corey Farwell-2/+2
Fixes #26554.
2016-11-04Change Into<Vec<u8>> for String and Into<OsString> for PathBuf to From implsleonardo.yvens-4/+4
2016-10-22Auto merge of #37327 - aidanhs:aphs-bytes-iter-doc, r=alexcrichtonbors-2/+2
`as_bytes` is not the iterator on String, `bytes` is r? @steveklabnik
2016-10-21`as_bytes` is not the iterator, `bytes` isAidan Hobson Sayers-2/+2
2016-10-21Implement `From<Cow<str>> for String` and `From<Cow<[T]>> for Vec<T>`.Simon Sapin-0/+7
Motivation: the `selectors` crate is generic over a string type, in order to support all of `String`, `string_cache::Atom`, and `gecko_string_cache::Atom`. Multiple trait bounds are used for the various operations done with these strings. One of these operations is creating a string (as efficiently as possible, re-using an existing memory allocation if possible) from `Cow<str>`. The `std::convert::From` trait seems natural for this, but the relevant implementation was missing before this PR. To work around this I’ve added a `FromCowStr` trait in `selectors`, but with trait coherence that means one of `selectors` or `string_cache` needs to depend on the other to implement this trait. Using a trait from `std` would solve this. The `Vec<T>` implementation is just added for consistency. I also tried a more general `impl<'a, O, B: ?Sized + ToOwned<Owned=O>> From<Cow<'a, B>> for O`, but (the compiler thinks?) it conflicts with `From<T> for T` the impl (after moving all of `collections::borrow` into `core::borrow` to work around trait coherence).
2016-10-10Add missing urls on String moduleGuillaume Gomez-3/+4
2016-09-30Rollup merge of #36623 - GuillaumeGomez:doc_typos, r=steveklabnikSteve Klabnik-3/+3
Fix some typos and improve doc comments style r? @steveklabnik
2016-09-28[breaking-change] std: change `encode_utf{8,16}()` to take a buffer and ↵tormol-3/+4
return a slice They panic if the buffer is too small.
2016-09-24Fix some typos and improve doc comments styleGuillaume Gomez-3/+3
2016-09-23Revert "implement `From<Vec<char>>` and `From<&'a [char]>` for `String`"Brian Anderson-20/+0
This reverts commit ac73335f2f5421c914fa3900567696cc6dc73d8d.
2016-09-11Documentation of what does for each typeathulappadan-0/+1
2016-08-23Auto merge of #35656 - Stebalien:fused, r=alexcrichtonbors-1/+4
Implement 1581 (FusedIterator) * [ ] Implement on patterns. See https://github.com/rust-lang/rust/issues/27721#issuecomment-239638642. * [ ] Handle OS Iterators. A bunch of iterators (`Args`, `Env`, etc.) in libstd wrap platform specific iterators. The current ones all appear to be well-behaved but can we assume that future ones will be? * [ ] Does someone want to audit this? On first glance, all of the iterators on which I implemented `FusedIterator` appear to be well-behaved but there are a *lot* of them so a second pair of eyes would be nice. * I haven't touched rustc internal iterators (or the internal rand) because rustc doesn't actually call `fuse()`. * `FusedIterator` can't be implemented on `std::io::{Bytes, Chars}`. Closes: #35602 (Tracking Issue) Implements: rust-lang/rfcs#1581
2016-08-21Fix "Furthermore" Typo in String DocsChristopher Serr-1/+1
It used to say "Furtheremore" instead of "Furthermore".
2016-08-18Add a FusedIterator trait.Steven Allen-1/+4
This trait can be used to avoid the overhead of a fuse wrapper when an iterator is already well-behaved. Conforming to: RFC 1581 Closes: #35602
2016-08-14Rollup merge of #35598 - tshepang:needless-binding, r=steveklabnikEduard-Mihai Burtescu-2/+1
string: remove needless binding
2016-08-14Rollup merge of #35597 - tshepang:it-is-a-slice, r=steveklabnikEduard-Mihai Burtescu-1/+1
doc: a value of type `&str` is called a "string slice"
2016-08-11string: remove needless bindingTshepang Lekhonkhobe-2/+1
2016-08-11doc: a value of type `&str` is called a "string slice"Tshepang Lekhonkhobe-1/+1
2016-08-09Add tracking issue for `String::insert_str`Murarth-1/+1
2016-08-07Add `FromIterator` implementations for `Cow<str>`Alexander Altman-0/+21
This seems like an oversight, since the corresponding implementation for `Cow<[T]> where T: Clone` exists.
2016-07-27implement `From<Vec<char>>` and `From<&'a [char]>` for `String`Paul Woolcock-0/+20
Though there are ways to convert a slice or vec of chars into a string, it would be nice to be able to just do `String::from(['a', 'b', 'c'])`, so this PR implements `From<Vec<char>>` and `From<&'a [char]>` for String.
2016-07-22Auto merge of #34771 - murarth:string-insert-str, r=alexcrichtonbors-9/+53
Add method `String::insert_str`
2016-07-21Rollup merge of #34890 - oconnor663:addassign, r=brsonGuillaume Gomez-1/+9
implement AddAssign for String Currently `String` implements `Add` but not `AddAssign`. This PR fills in that gap. I played around with having `AddAssign` (and `Add` and `push_str`) take `AsRef<str>` instead of `&str`, but it looks like that breaks arguments that implement `Deref<Target=str>` and not `AsRef<str>`. Comments in [`libcore/convert.rs`](https://github.com/rust-lang/rust/blob/master/src/libcore/convert.rs#L207-L213) make it sound like we could fix this with a blanket impl eventually. Does anyone know what's blocking that?
2016-07-18use a new feature name for String AddAssignJack O'Connor-1/+1
2016-07-18update the since field to 1.12.0 for String AddAssignJack O'Connor-1/+1
2016-07-17Document from_raw_parts involves ownership transferJake Goulding-0/+6
2016-07-17implement AddAssign for StringJack O'Connor-1/+9
2016-07-11Add method `String::insert_str`Murarth-9/+53
2016-05-12doc: Fix comment in std::string::String example codeHaiko Schol-1/+1
2016-04-15std: Change String::truncate to panic lessAlex Crichton-4/+8
The `Vec::truncate` method does not panic if the length argument is greater than the vector's current length, but `String::truncate` will indeed panic. This semantic difference can be a bit jarring (e.g. #32717), and after some discussion the libs team concluded that although this can technically be a breaking change it is almost undoubtedly not so in practice. This commit changes the semantics of `String::truncate` to be a noop if `new_len` is greater than the length of the current string. Closes #32717
2016-04-11std: Stabilize APIs for the 1.9 releaseAlex Crichton-10/+11
This commit applies all stabilizations, renamings, and deprecations that the library team has decided on for the upcoming 1.9 release. All tracking issues have gone through a cycle-long "final comment period" and the specific APIs stabilized/deprecated are: Stable * `std::panic` * `std::panic::catch_unwind` (renamed from `recover`) * `std::panic::resume_unwind` (renamed from `propagate`) * `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`) * `std::panic::UnwindSafe` (renamed from `RecoverSafe`) * `str::is_char_boundary` * `<*const T>::as_ref` * `<*mut T>::as_ref` * `<*mut T>::as_mut` * `AsciiExt::make_ascii_uppercase` * `AsciiExt::make_ascii_lowercase` * `char::decode_utf16` * `char::DecodeUtf16` * `char::DecodeUtf16Error` * `char::DecodeUtf16Error::unpaired_surrogate` * `BTreeSet::take` * `BTreeSet::replace` * `BTreeSet::get` * `HashSet::take` * `HashSet::replace` * `HashSet::get` * `OsString::with_capacity` * `OsString::clear` * `OsString::capacity` * `OsString::reserve` * `OsString::reserve_exact` * `OsStr::is_empty` * `OsStr::len` * `std::os::unix::thread` * `RawPthread` * `JoinHandleExt` * `JoinHandleExt::as_pthread_t` * `JoinHandleExt::into_pthread_t` * `HashSet::hasher` * `HashMap::hasher` * `CommandExt::exec` * `File::try_clone` * `SocketAddr::set_ip` * `SocketAddr::set_port` * `SocketAddrV4::set_ip` * `SocketAddrV4::set_port` * `SocketAddrV6::set_ip` * `SocketAddrV6::set_port` * `SocketAddrV6::set_flowinfo` * `SocketAddrV6::set_scope_id` * `<[T]>::copy_from_slice` * `ptr::read_volatile` * `ptr::write_volatile` * The `#[deprecated]` attribute * `OpenOptions::create_new` Deprecated * `std::raw::Slice` - use raw parts of `slice` module instead * `std::raw::Repr` - use raw parts of `slice` module instead * `str::char_range_at` - use slicing plus `chars()` plus `len_utf8` * `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8` * `str::char_at` - use slicing plus `chars()` * `str::char_at_reverse` - use slicing plus `chars().rev()` * `str::slice_shift_char` - use `chars()` plus `Chars::as_str` * `CommandExt::session_leader` - use `before_exec` instead. Closes #27719 cc #27751 (deprecating the `Slice` bits) Closes #27754 Closes #27780 Closes #27809 Closes #27811 Closes #27830 Closes #28050 Closes #29453 Closes #29791 Closes #29935 Closes #30014 Closes #30752 Closes #31262 cc #31398 (still need to deal with `before_exec`) Closes #31405 Closes #31572 Closes #31755 Closes #31756
2016-03-31Auto merge of #32586 - seanmonstar:speialize-to-string, r=alexcrichtonbors-1/+9
specialize ToString for str If there was some conditional compiling we could do, such that this impl only exists in nightly, and is turned off in beta/stable, I think that'd be an improvement here, as we could test specialization out without affecting stable builds.
2016-03-30specialize ToString for strSean McArthur-1/+9
2016-03-28style: Use `iter` for IntoIterator parameter namesKamal Marhubi-14/+14
This commit standardizes the codebase on `iter` for parameters with IntoIterator bounds. Previously about 40% of IntoIterator parameters were named `iterable`, with most of the rest being named `iter`. There was a single place where it was named `iterator`.
2016-03-22std: Change `encode_utf{8,16}` to return iteratorsAlex Crichton-20/+5
Currently these have non-traditional APIs which take a buffer and report how much was filled in, but they're not necessarily ergonomic to use. Returning an iterator which *also* exposes an underlying slice shouldn't result in any performance loss as it's just a lazy version of the same implementation, and it's also much more ergonomic! cc #27784
2016-03-13Call str::to_owned in String::from and uninline itUlrik Sverdrup-14/+2
String::from does not need to be inlined, it can be without it just like str::to_owned and String::clone are.
2016-03-12std: Clean out deprecated APIsAlex Crichton-22/+1
Removes all unstable and deprecated APIs prior to the 1.8 release. All APIs that are deprecated in the 1.8 release are sticking around for the rest of this cycle. Some notable changes are: * The `dynamic_lib` module was moved into `rustc_back` as the compiler still relies on a few bits and pieces. * The `DebugTuple` formatter now special-cases an empty struct name with only one field to append a trailing comma.
2016-03-08doc: Fix a bunch of broken linksAlex Crichton-27/+27
A few categories: * Links into compiler docs were just all removed as we're not generating compiler docs. * Move up one more level to forcibly go to std docs to fix inlined documentation across the facade crates.
2016-02-27add indexing with RangeInclusive in libcore and libcollectionsAlex Burka-1/+33
2016-02-09Rollup merge of #31515 - steveklabnik:doc_drain, r=alexcrichtonSteve Klabnik-0/+6
This is the last bit of String docs needed to Close #29376
2016-02-09Improve docs for Drain on StringSteve Klabnik-0/+6
This is the last bit of String docs needed to Close #29376
2016-02-09Minor spelling fixesCarlos E. Garcia-1/+1
2016-02-08Fix up docs for String::from_utf8_lossy()Steve Klabnik-11/+12
When I last did a pass through the string documentation, I focused on consistency across similar functions. Unfortunately, I missed some details. This example was _too_ consistent: it wasn't actually accurate! This commit fixes the docs do both be more accurate and to explain why the return type is a Cow<'a, str>. First reported here: https://www.reddit.com/r/rust/comments/44q9ms/stringfrom_utf8_lossy_doesnt_return_a_string/
2016-02-01docs: Standardize on 'Errors' header in std docsKamal Marhubi-1/+1