summary refs log tree commit diff
path: root/src/libcollections/string.rs
AgeCommit message (Collapse)AuthorLines
2015-09-11std: Stabilize/deprecate features for 1.4Alex Crichton-4/+2
The FCP is coming to a close and 1.4 is coming out soon, so this brings in the libs team decision for all library features this cycle. Stabilized APIs: * `<Box<str>>::into_string` * `Arc::downgrade` * `Arc::get_mut` * `Arc::make_mut` * `Arc::try_unwrap` * `Box::from_raw` * `Box::into_raw` * `CStr::to_str` * `CStr::to_string_lossy` * `CString::from_raw` * `CString::into_raw` * `IntoRawFd::into_raw_fd` * `IntoRawFd` * `IntoRawHandle::into_raw_handle` * `IntoRawHandle` * `IntoRawSocket::into_raw_socket` * `IntoRawSocket` * `Rc::downgrade` * `Rc::get_mut` * `Rc::make_mut` * `Rc::try_unwrap` * `Result::expect` * `String::into_boxed_slice` * `TcpSocket::read_timeout` * `TcpSocket::set_read_timeout` * `TcpSocket::set_write_timeout` * `TcpSocket::write_timeout` * `UdpSocket::read_timeout` * `UdpSocket::set_read_timeout` * `UdpSocket::set_write_timeout` * `UdpSocket::write_timeout` * `Vec::append` * `Vec::split_off` * `VecDeque::append` * `VecDeque::retain` * `VecDeque::split_off` * `rc::Weak::upgrade` * `rc::Weak` * `slice::Iter::as_slice` * `slice::IterMut::into_slice` * `str::CharIndices::as_str` * `str::Chars::as_str` * `str::split_at_mut` * `str::split_at` * `sync::Weak::upgrade` * `sync::Weak` * `thread::park_timeout` * `thread::sleep` Deprecated APIs * `BTreeMap::with_b` * `BTreeSet::with_b` * `Option::as_mut_slice` * `Option::as_slice` * `Result::as_mut_slice` * `Result::as_slice` * `f32::from_str_radix` * `f64::from_str_radix` Closes #27277 Closes #27718 Closes #27736 Closes #27764 Closes #27765 Closes #27766 Closes #27767 Closes #27768 Closes #27769 Closes #27771 Closes #27773 Closes #27775 Closes #27776 Closes #27785 Closes #27792 Closes #27795 Closes #27797
2015-08-28Auto merge of #28038 - durka:grep-unstable-issue-refs, r=alexcrichtonbors-1/+2
After submitting #28031, I ran a [script](https://gist.github.com/durka/a5243440697c780f669b) on the rest of src/ and found some anomalies. In this PR are the fixes that I thought were obvious (but I might be wrong!). The others I've submitted in issue #28037.
2015-08-27fix some more unstable issue annotationsAlex Burka-1/+2
2015-08-27Implemented Extend<String> and FromIterator<String> for String.Without Boats-6/+24
2015-08-27Auto merge of #27808 - SimonSapin:utf16decoder, r=alexcrichtonbors-10/+3
* Rename `Utf16Items` to `Utf16Decoder`. "Items" is meaningless. * Generalize it to any `u16` iterator, not just `[u16].iter()` * Make it yield `Result` instead of a custom `Utf16Item` enum that was isomorphic to `Result`. This enable using the `FromIterator for Result` impl. * Replace `Utf16Item::to_char_lossy` with a `Utf16Decoder::lossy` iterator adaptor. This is a [breaking change], but only for users of the unstable `rustc_unicode` crate. I’d like this functionality to be stabilized and re-exported in `std` eventually, as the "low-level equivalent" of `String::from_utf16` and `String::from_utf16_lossy` like #27784 is the low-level equivalent of #27714. CC @aturon, @alexcrichton
2015-08-25Simplify `String`’s `Extend<&str>` implementationChris Morgan-5/+1
Reserving lower_bound bytes was just silly. It’d be perfectly reasonable to have empty strings in the iterator, which could cause superfluous reallocation of the string, or to have more than one byte per string, which could cause additional reallocation (in practice it’ll balance out). The added complexity of this logic is simply pointless, adding a little bloat with no demonstrable advantage and slight disadvantage.
2015-08-23Refactor low-level UTF-16 decoding.Simon Sapin-10/+3
* Rename `utf16_items` to `decode_utf16`. "Items" is meaningless. * Move it to `rustc_unicode::char`, exposed in `std::char`. * Generalize it to any `u16` iterable, not just `&[u16]`. * Make it yield `Result` instead of a custom `Utf16Item` enum that was isomorphic to `Result`. This enable using the `FromIterator for Result` impl. * Add a `REPLACEMENT_CHARACTER` constant. * Document how `result.unwrap_or(REPLACEMENT_CHARACTER)` replaces `Utf16Item::to_char_lossy`.
2015-08-15collections: Add issues for unstable featuresAlex Crichton-10/+16
2015-08-14Auto merge of #27696 - bluss:into-boxed-str, r=alexcrichtonbors-1/+11
Rename String::into_boxed_slice -> into_boxed_str This is the name that was decided in rust-lang/rfcs#1152, and it's better if we say “boxed str” for `Box<str>`. The old name `String::into_boxed_slice` is deprecated.
2015-08-13Rename String::into_boxed_slice -> into_boxed_strUlrik Sverdrup-1/+11
This is the name that was decided in rust-lang/rfcs#1152, and it's better if we say “boxed str” for `Box<str>`. The old name `String::into_boxed_slice` is deprecated.
2015-08-12Remove all unstable deprecated functionalityAlex Crichton-18/+0
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-11Register new snapshotsAlex Crichton-3/+0
* Lots of core prelude imports removed * Makefile support for MSVC env vars and Rust crates removed * Makefile support for morestack removed
2015-08-09Replace many uses of `mem::transmute` with more specific functionsTobias Bucher-3/+3
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`.
2015-08-03syntax: Implement #![no_core]Alex Crichton-1/+2
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-07-27Show appropriate feature flags in docsSteve Klabnik-2/+3
2015-07-20Register new snapshotsAlex Crichton-3/+0
These new snapshots contain the knowledge of how to build the new triples of 32-bit MSVC and 32-bit FreeBSD, both of which should soon start having nightlies/auto builders! This does not currently register bitrig/freebsd snapshots but I believe those will be retroactively added in the near future.
2015-07-17Add RawVec to unify raw Vecish codeAlexis Beingessner-44/+1
2015-07-13Implement IndexMut for String and str.Simon Sapin-0/+32
... 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-13Implement DerefMut for StringSimon Sapin-0/+8
`&mut str` is rarely useful, but it is for e.g. `AsciiExt::make_ascii_lowercase`.
2015-07-11Add String::into_boxed_slice and Box<str>::into_stringJonathan Reem-0/+11
Implements merged RFC 1152. Closes #26697.
2015-07-02Add more description for from_raw_parts's unsafetySteve Klabnik-2/+7
Fixes #26737.
2015-06-17collections: Split the `collections` featureAlex Crichton-6/+13
This commit also deprecates the `as_string` and `as_slice` free functions in the `string` and `vec` modules.
2015-06-10Modify String::push to reallocate more conservatively in case of the ↵marcell-17/+17
character's UTF-8 representation is bigger than 1 byte
2015-06-08Auto merge of #26077 - SimonSapin:patch-6, r=alexcrichtonbors-5/+5
With the latter is provided by the `From` conversion trait, the former is now completely redundant. Their code is identical. Let’s deprecate now and plan to remove in the next cycle. (It’s `#[unstable]`.) r? @alexcrichton CC @nagisa
2015-06-08Auto merge of #25989 - jooert:implement_rfc839, r=Gankrobors-0/+7
I had to use `impl<'a, V: Copy> Extend<(usize, &'a V)> for VecMap<V>` instead of `impl<'a, V: Copy> Extend<(&'a usize, &'a V)> for VecMap<V>` as that's what is needed for doing ```rust let mut a = VecMap::new(); let b = VecMap::new(); b.insert(1, "foo"); a.extend(&b) ``` I can squash the commits after review. r? @Gankro
2015-06-08Replace usage of String::from_str with String:fromSimon Sapin-3/+3
2015-06-08Implement RFC 839Johannes Oertel-0/+7
Closes #25976.
2015-06-07Deprecate String::from_str in favor of String::fromSimon Sapin-2/+2
With the latter is provided by the `From` conversion trait, the former is now completely redundant. Their code is identical.
2015-06-06Remove many unneeded feature annotations in the docsSteve Klabnik-1/+1
When things get stabilized, they don't always have their docs updated to remove the gate.
2015-06-01doc: make String::as_bytes example more simpleTshepang Lekhonkhobe-2/+1
2015-05-19collections: Avoid unstable code in examples for StringUlrik Sverdrup-21/+9
Prefer String::from over from_str; String::from_str is unstable while String::from is stable. Promote the latter by using it in examples. Simply migrating unstable function to the closest alternative.
2015-05-16Fixed reserve_exact exampleMário Feroldi-1/+1
The same example for ``reverse`` were in the ``reserve_exact``'s example.
2015-05-10Rollup merge of #25158 - koute:master, r=alexcrichtonSteve Klabnik-0/+1
I was profiling my code again and this time AsRef<str> for String was eating up a considerable chunk of my runtime; adding the inline annotation made the program run almost twice as fast! While I was at it I also added the annotation to other implementations of AsRef as well as AsMut.
2015-05-10Add #[inline] to AsRef<str>::as_ref for String and str.Jan Bujak-0/+1
2015-05-08collections: impl AsRef<[u8]> for StringSean McArthur-0/+8
2015-05-04Fix spelling errors in documentation.Joseph Crail-1/+1
2015-05-02Auto merge of #25028 - bluss:drain-string, r=alexcrichtonbors-1/+107
collections: Implement String::drain(range) according to RFC 574 `.drain(range)` is unstable and under feature(collections_drain). This adds a safe way to remove any range of a String as efficiently as possible. As noted in the code, this drain iterator has none of the memory safety issues of the vector version. RFC tracking issue is #23055
2015-05-01collections: Implement String::drain(range) according to RFC 574Ulrik Sverdrup-1/+107
`.drain(range)` is unstable and under feature(collections_drain). This adds a safe way to remove any range of a String as efficiently as possible. As noted in the code, this drain iterator has none of the memory safety issues of the vector version. RFC tracking issue is #23055
2015-05-01std: Remove index notation on slice iteratorsAlex Crichton-9/+12
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791
2015-04-27collections: Improve example for as_string and as_vecUlrik Sverdrup-4/+5
2015-04-21Test fixes and rebase conflicts, round 1Alex Crichton-1/+0
2015-04-21rollup merge of #24636: alexcrichton/remove-deprecatedAlex Crichton-17/+0
Conflicts: src/libcore/result.rs
2015-04-21rollup merge of #24541: alexcrichton/issue-24538Alex Crichton-2/+2
This is an implementation of [RFC 1030][rfc] which adds these traits to the prelude and additionally removes all inherent `into_iter` methods on collections in favor of the trait implementation (which is now accessible by default). [rfc]: https://github.com/rust-lang/rfcs/pull/1030 This is technically a breaking change due to the prelude additions and removal of inherent methods, but it is expected that essentially no code breaks in practice. [breaking-change] Closes #24538
2015-04-21rollup merge of #24661: SimonSapin/fmt-write-charAlex Crichton-0/+6
as accepted in [RFC 526](https://github.com/rust-lang/rfcs/blob/master/text/0526-fmt-text-writer.md). Note that this brand new method is marked as **stable**. I judged this safe enough: it’s simple enough that it’s very unlikely to change. Still, I can mark it unstable instead if you prefer. r? @alexcrichton
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-8/+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-9/+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-21Add a `write_char` method to `std::fmt::Write`Simon Sapin-0/+6
as accepted in [RFC 526](https://github.com/rust-lang/rfcs/blob/master/text/0526-fmt-text-writer.md).
2015-04-21Model lexer: Fix remaining issuesPiotr Czarnecki-2/+0
2015-04-19collections: Move optimized String::from_str to String::fromErick Tryzelaar-1/+12
This implementation is currently about 3-4 times faster than using the `.to_string()` based approach.