about summary refs log tree commit diff
path: root/src/liballoc/string.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-2504/+0
2020-07-25Document UTF-8 validity of String::from_raw_partsaticu-0/+1
2020-07-25Fix wrong name in `String::from_raw_parts` docsaticu-2/+2
2020-07-23Prefer type@strLzu Tao-3/+3
2020-07-23Make str point to primitive pageLzu Tao-1/+2
2020-07-20Auto merge of #74010 - pierwill:pierwill-o-notation, r=GuillaumeGomezbors-4/+4
Use italics for O notation In documentation, I think it makes sense to italicize O notation (*O(n)*) as opposed to using back-ticks (`O(n)`). Visually, back-ticks focus the reader on the literal characters being used, making them ideal for representing code. Using italics, as far I can tell, more closely follows typographic conventions in mathematics and computer science. Just a suggestion, of course! 😇
2020-07-19Use italics for O notationpierwill-4/+4
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2020-07-18Clarify the literal stringManish Goregaokar-1/+1
2020-07-18Use intra-doc links in alloc::StringManish Goregaokar-86/+44
2020-07-05Rollup merge of #72688 - djugei:master, r=AmanieuManish Goregaokar-0/+16
added .collect() into String from Box<str> I have not created an rfc, because i felt like this is a very minor change. i have just set a random feature name and rust version as stability attribute, i expect to have to change that, i just don't know what the policy on that is. all guides i could find focused on contributing to the compiler, not contributing to the standard library. drawbacks: more code in the standard library, could be replaced with specialization: base-implementation for AsRef\<str> and specialization for String and Cow. i can write that code if ppl want it. advantages: using "real strings" i.e. Box\<str> is as ergonomic as string slices (&str) and string buffers (String) with iterators.
2020-07-01Rollup merge of #73466 - matthiaskrgr:char_into_string, r=dtolnayManish Goregaokar-0/+8
impl From<char> for String This allows us to write ````rust fn char_to_string() -> String { 'a'.into() } ```` which was not possible before.
2020-06-19Rollup merge of #73465 - lzutao:spec-char-tostring, r=sfacklerManish Goregaokar-0/+8
Add specialization of `ToString for char` Closes #73462
2020-06-19`#[deny(unsafe_op_in_unsafe_fn)]` in liballocLeSeulArtichaut-4/+6
2020-06-18impl From<char> for StringMatthias Krüger-0/+8
This allows us to write fn char_to_string() -> String { 'a'.into() } which was not possible before.
2020-06-18Add specialization of `ToString for char`Lzu Tao-0/+8
2020-05-29Add Extend::{extend_one,extend_reserve}Josh Stone-0/+35
This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-05-27added .collect() into String from Box<str> with fake feature/stability ↵djugei-0/+16
annotation
2020-04-22More diagnostic items for Clippy usagePhilipp Hansch-0/+1
This adds a couple of more diagnostic items to be used in Clippy. I chose these particular ones because they were the types which we seem to check for the most in Clippy. I'm not sure if the `cfg_attr(not(test))` is needed, but it was also used for `Vec` and a few other types.
2020-04-14Rollup merge of #71121 - AnthonyMikh:fix_string_doc_link, r=Dylan-DPCDylan DPC-0/+1
Fix broken link in documentation for String::from_utf8
2020-04-14Fix broken link in documentation for String::from_utf8AnthonyMikh-0/+1
2020-04-13Add examples to Pattern docsIvan Tham-0/+6
2020-04-13Add period to Pattern docsIvan Tham-1/+1
2020-03-30Optimize strip_prefix and strip_suffix with str patternsNikhil Benesch-0/+15
Constructing a Searcher in strip_prefix and strip_suffix is unnecessarily slow when the pattern is a fixed-length string. Add strip_prefix and strip_suffix methods to the Pattern trait, and add optimized implementations of these methods in the str implementation. The old implementation is retained as the default for these methods.
2020-03-24must_use on split_offKornel-0/+1
#70194
2020-03-15Rollup merge of #69661 - lopopolo:string-from-mut-str, r=sfacklerMazdak Farrokhzad-0/+11
Implement From<&mut str> for String I ran into this missing impl when trying to do `String::from` on the result returned from this API in the `uuid` crate: https://docs.rs/uuid/0.8.1/uuid/adapter/struct.Hyphenated.html#method.encode_lower I wasn't sure what to put in the stability annotation. I'd appreciate some help with that :)
2020-03-10Add docs for From::<&mut str>::from String implRyan Lopopolo-0/+3
2020-03-10Add stable feature nameRyan Lopopolo-1/+1
2020-03-05Fixed a typoTrolledWoods-1/+1
"vector" was used instead of "string"
2020-03-02Implement From<&mut str> for StringRyan Lopopolo-0/+8
2020-02-19Change FromStr for String to use Infallible directlyPeter Todd-11/+4
Fixes the confusing documentation on `ParseError` by making it irrelevant.
2020-02-09Rollup merge of #68742 - tspiteri:string-as-mut, r=sfacklerJonas Schievink-0/+8
implement AsMut<str> for String Closes #68741.
2020-02-01implement AsMut<str> for StringTrevor Spiteri-0/+8
2020-02-02Derive Clone + PartialEq + Eq for std::string::FromUtf8Errorkennytm-1/+1
2019-12-22Format the worldMark Rousskov-59/+54
2019-12-18Propagate cfg bootstrapMark Rousskov-4/+1
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-0/+4
functions with a `const` modifier
2019-11-07Rollup merge of #66111 - RalfJung:from_raw_parts, r=CentrilYuki Okushi-1/+1
improve from_raw_parts docs Triggered by https://github.com/rust-lang/rfcs/pull/2806. Hopefully this helps clarify that joining slices across allocations is not possible in Rust currently. r? @Centril
2019-11-05also edit String::from_raw_parts while we are at itRalf Jung-1/+1
2019-11-01doc(str): show example of chars().count() under len()Jeff Dickey-2/+7
the docs are great at explaining that .len() isn't like in other languages but stops short of explaining how to get the character length. r? @steveklabnik
2019-10-25Add {String,Vec}::into_raw_partsJake Goulding-0/+33
2019-10-25Use ManuallyDrop in examples for {Vec,String}::from_raw_partsJake Goulding-7/+9
2019-10-25Remove unneeded pointer castingJake Goulding-6/+6
2019-10-01Remove unneeded `fn main` blocks from docsLzu Tao-4/+2
2019-09-25Snap cfgs to new betaMark Rousskov-1/+0
2019-09-24fix several issues in String docsjordins-4/+4
- In some places &str was shown instead of String. - into_bytes is the reverse of from_utf8 Fixes #63797
2019-09-16Const-stabilize `String::new`.Mazdak Farrokhzad-1/+1
2019-08-16Rename CollectionAllocError to TryReserveErrorSimon Sapin-7/+7
2019-07-28Deny `unused_lifetimes` through rustbuildVadim Petrochenkov-0/+2
2019-07-05Rollup merge of #62123 - jeremystucki:needless_lifetimes_std, r=alexcrichtonMazdak Farrokhzad-1/+1
Remove needless lifetimes (std) Split from #62039
2019-07-02When possible without changing semantics, implement Iterator::last in terms ↵Kyle Huey-0/+5
of DoubleEndedIterator::next_back for types in liballoc and libcore. Provided that the iterator has finite length and does not trigger user-provided code, this is safe. What follows is a full list of the DoubleEndedIterators in liballoc/libcore and whether this optimization is safe, and if not, why not. src/liballoc/boxed.rs Box: Pass through to avoid defeating optimization of the underlying DoubleIterator implementation. This has no correctness impact. src/liballoc/collections/binary_heap.rs Iter: Pass through to avoid defeating optimizations on slice::Iter IntoIter: Not safe, changes Drop order Drain: Not safe, changes Drop order src/liballoc/collections/btree/map.rs Iter: Safe to call next_back, invokes no user defined code. IterMut: ditto IntoIter: Not safe, changes Drop order Keys: Safe to call next_back, invokes no user defined code. Values: ditto ValuesMut: ditto Range: ditto RangeMut: ditto src/liballoc/collections/btree/set.rs Iter: Safe to call next_back, invokes no user defined code. IntoIter: Not safe, changes Drop order Range: Safe to call next_back, invokes no user defined code. src/liballoc/collections/linked_list.rs Iter: Safe to call next_back, invokes no user defined code. IterMut: ditto IntoIter: Not safe, changes Drop order src/liballoc/collections/vec_deque.rs Iter: Safe to call next_back, invokes no user defined code. IterMut: ditto IntoIter: Not safe, changes Drop order Drain: ditto src/liballoc/string.rs Drain: Safe because return type is a primitive (char) src/liballoc/vec.rs IntoIter: Not safe, changes Drop order Drain: ditto Splice: ditto src/libcore/ascii.rs EscapeDefault: Safe because return type is a primitive (u8) src/libcore/iter/adapters/chain.rs Chain: Not safe, invokes user defined code (Iterator impl) src/libcore/iter/adapters/flatten.rs FlatMap: Not safe, invokes user defined code (Iterator impl) Flatten: ditto FlattenCompat: ditto src/libcore/iter/adapters/mod.rs Rev: Not safe, invokes user defined code (Iterator impl) Copied: ditto Cloned: Not safe, invokes user defined code (Iterator impl and T::clone) Map: Not safe, invokes user defined code (Iterator impl + closure) Filter: ditto FilterMap: ditto Enumerate: Not safe, invokes user defined code (Iterator impl) Skip: ditto Fuse: ditto Inspect: ditto src/libcore/iter/adapters/zip.rs Zip: Not safe, invokes user defined code (Iterator impl) src/libcore/iter/range.rs ops::Range: Not safe, changes Drop order, but ALREADY HAS SPECIALIZATION ops::RangeInclusive: ditto src/libcore/iter/sources.rs Repeat: Not safe, calling last should iloop. Empty: No point, iterator is at most one item long. Once: ditto OnceWith: ditto src/libcore/option.rs Item: No point, iterator is at most one item long. Iter: ditto IterMut: ditto IntoIter: ditto src/libcore/result.rs Iter: No point, iterator is at most one item long IterMut: ditto IntoIter: ditto src/libcore/slice/mod.rs Split: Not safe, invokes user defined closure SplitMut: ditto RSplit: ditto RSplitMut: ditto Windows: Safe, already has specialization Chunks: ditto ChunksMut: ditto ChunksExact: ditto ChunksExactMut: ditto RChunks: ditto RChunksMut: ditto RChunksExact: ditto RChunksExactMut: ditto src/libcore/str/mod.rs Chars: Safe, already has specialization CharIndices: ditto Bytes: ditto Lines: Safe to call next_back, invokes no user defined code. LinesAny: Deprecated Everything that is generic over P: Pattern: Not safe because Pattern invokes user defined code. SplitWhitespace: Safe to call next_back, invokes no user defined code. SplitAsciiWhitespace: ditto