about summary refs log tree commit diff
path: root/src/liballoc/str.rs
AgeCommit message (Collapse)AuthorLines
2018-04-17Rollup merge of #49555 - nox:inline-into-boxed, r=alexcrichtonkennytm-0/+3
Inline most of the code paths for conversions with boxed slices This helps with the specific problem described in #49541, obviously without making any large change to how inlining works in the general case. Everything involved in the conversions is made `#[inline]`, except for the `<Vec<T>>::into_boxed_slice` entry point which is made `#[inline(always)]` after checking that duplicating the function mentioned in the issue prevented its inlining if I only annotate it with `#[inline]`. For the record, that function was: ```rust pub fn foo() -> Box<[u8]> { vec![0].into_boxed_slice() } ``` To help the inliner's job, we also hoist a `self.capacity() != self.len` check in `<Vec<T>>::shrink_to_fit` and mark it as `#[inline]` too.
2018-04-14Cleanup liballoc use statementsMike Hommey-3/+3
Some modules were still using the deprecated `allocator` module, use the `alloc` module instead. Some modules were using `super` while it's not needed. Some modules were more or less ordering them, and other not, so the latter have been modified to match the others.
2018-04-12Merge unstable Utf16Encoder into EncodeUtf16Simon Sapin-5/+22
2018-04-12Merge core::unicode::str into core::strSimon Sapin-8/+8
And the UnicodeStr trait into StrExt
2018-04-12Deprecate the std_unicode crateSimon Sapin-4/+3
2018-04-01Inline most of the code paths for conversions with boxed slicesAnthony Ramine-0/+3
This helps with the specific problem described in #49541, obviously without making any large change to how inlining works in the general case. Everything involved in the conversions is made `#[inline]`, except for the `<Vec<T>>::into_boxed_slice` entry point which is made `#[inline(always)]` after checking that duplicating the function mentioned in the issue prevented its inlining if I only annotate it with `#[inline]`. For the record, that function was: ```rust pub fn foo() -> Box<[u8]> { vec![0].into_boxed_slice() } ``` To help the inliner's job, we also hoist a `self.capacity() != self.len` check in `<Vec<T>>::shrink_to_fit` and mark it as `#[inline]` too.
2018-03-28Add repeat method on sliceGuillaume Gomez-53/+1
2018-03-26Add is_whitespace and is_alphanumeric to str.boats-0/+42
The other methods from `UnicodeStr` are already stable inherent methods on str, but these have not been included.
2018-03-06Rollup merge of #47463 - bluss:fused-iterator, r=alexcrichtonkennytm-1/+1
Stabilize FusedIterator FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate. Closes #35602
2018-03-04Avoid unnecessary calculationShotaro Yamada-3/+3
2018-03-04Add commentsShotaro Yamada-20/+40
2018-03-03core: Update stability attributes for FusedIteratorUlrik Sverdrup-1/+1
2018-03-03core: Stabilize FusedIteratorUlrik Sverdrup-1/+1
FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate.
2018-03-02Optimize str::repeatShotaro Yamada-3/+34
2017-12-27update char_indices example to highlight big charsQuietMisdreavus-2/+6
2017-12-02Mark ascii methods on primitive types stable in 1.23.0.Ralph Giles-6/+6
The ascii_methods_on_intrinsics feature stabilization didn't land in time for 1.21.0. Update the annotation so the documentation is correct about when these methods became available.
2017-11-29Update bootstrap compilerAlex Crichton-5/+0
Also remove a number of `stage0` annotations and such
2017-11-29Rollup merge of #46077 - LukasKalbertodt:stabilize-ascii-ctype, r=alexcrichtonkennytm-147/+0
Stabilize some `ascii_ctype` methods As discussed in #39658, this PR stabilizes those methods for `u8` and `char`. All inherent `ascii_ctype` for `[u8]` and `str` are removed as we prefer the more explicit version `s.chars().all(|c| c.is_ascii_())`. This PR doesn't modify the `AsciiExt` trait. There, the `ascii_ctype` methods are still unstable. It is planned to remove those in the future (I think). I had to modify some code in `ascii.rs` to properly implement `AsciiExt` for all types. Fixes #39658.
2017-11-20Fix result for assert_eqBenjamin Hoffmeyer-1/+1
2017-11-20Fix doc tests for trim_right_matchesBenjamin Hoffmeyer-1/+1
2017-11-18Remove inherent `ascii_ctype` methods from `str` and `[u8]`Lukas Kalbertodt-147/+0
This has been discussed in #39658. It's a bit ambiguous how those methods work for a sequence of ascii values. We prefer users writing `s.iter().all(|b| b.is_ascii_...())` explicitly. The AsciiExt methods still exist and are implemented for `str` and `[u8]`. We will deprecated or remove those later.
2017-11-14Fixed several pulldown warnings when documenting libstd.kennytm-1/+1
2017-11-08get() example should use get() not get_mut()John Ford-4/+4
I'm really new to Rust, this is the first thing I've ever actually pushed to github in a rust project, so please double check that it's correct. I noticed that the in-doc example for the string's get() function was referring to get_mut(). Looks like a copy/paste issue. ```rust fn main() { let v = String::from("🗻∈🌏"); assert_eq!(Some("🗻"), v.get(0..4)); // indices not on UTF-8 sequence boundaries assert!(v.get(1..).is_none()); assert!(v.get(..8).is_none()); // out of bounds assert!(v.get(..42).is_none()); } ``` results in: ``` jhford-work:~/rust/redish $ cat get-example.rs fn main() { let v = String::from("🗻∈🌏"); assert_eq!(Some("🗻"), v.get(0..4)); // indices not on UTF-8 sequence boundaries assert!(v.get(1..).is_none()); assert!(v.get(..8).is_none()); // out of bounds assert!(v.get(..42).is_none()); } jhford-work:~/rust/redish $ rustc get-example.rs jhford-work:~/rust/redish $ ./get-example ; echo $? 0 ``` I did not build an entire rust toolchain as I'm not totally sure how to do that.
2017-11-03Mark several ascii methods as unstable againLukas Kalbertodt-10/+14
We don't want to stabilize them now already. The goal of this set of commits is just to add inherent methods to the four types. Stabilizing all of those methods can be done later.
2017-11-03Remove unused AsciiExt imports and fix tests related to ascii methodsLukas Kalbertodt-4/+0
Many AsciiExt imports have become useless thanks to the inherent ascii methods added in the last commits. These were removed. In some places, I fully specified the ascii method being called to enforce usage of the AsciiExt trait. Note that some imports are not removed but tagged with a `#[cfg(stage0)]` attribute. This is necessary, because certain ascii methods are not yet available in stage0. All those imports will be removed later. Additionally, failing tests were fixed. The test suite should exit successfully now.
2017-11-03Copy `AsciiExt` methods to `str` directlyLukas Kalbertodt-0/+276
This is done in order to deprecate AsciiExt eventually. Note that this commit contains a bunch of `cfg(stage0)` statements. This is due to a new compiler feature this commit depends on: the `slice_u8` lang item. Once this lang item is available in the stage0 compiler, all those cfg flags (and more) can be removed.
2017-10-17added non trivial examples of closures for str::findChristian Poveda-2/+2
2017-10-17added examples of closuresChristian Poveda-1/+3
2017-09-27Remove mem::transmute used in Box<str> conversionsNikolai Vazquez-5/+3
2017-09-14Rollup merge of #44521 - rwakulszowa:str_utf16_doc, r=frewsxcvCorey Farwell-0/+13
Add an example of std::str::encode_utf16 Closes #44419
2017-09-14Rollup merge of #44497 - tommyip:doc_example, r=frewsxcvCorey Farwell-0/+11
Add doc example to str::from_boxed_utf8_unchecked Fixes #44463.
2017-09-12Add an example of std::str::encode_utf16rwakulszowa-0/+13
Closes #44419
2017-09-11Add doc example to str::from_boxed_utf8_uncheckedTommy Ip-0/+11
Fixes #44463.
2017-09-11Removed trailing whitespace42triangles-1/+1
2017-09-11Added an example for `std::str::into_boxed_bytes()`42triangles-0/+11
2017-09-10Rollup merge of #44467 - toidiu:ak-44382, r=frewsxcvGuillaume Gomez-7/+16
documentation update to demonstrate mutability #44467 - demonstrate correct implementation returns `Some` - demonstrate out of bounds returns `None` - demonstrate mutability
2017-09-09documentation update to demonstrate mutabilitytoidiu-7/+16
2017-09-09Add doc examples for str::as_bytes_mutEthan Dagner-0/+28
Fixes #44427
2017-08-24Fix inconsistent doc headingslukaramu-1/+1
This fixes headings reading "Unsafety" and "Example", they should be "Safety" and "Examples" according to RFC 1574.
2017-08-05Indicate how to turn byte slices back into a string slice.Corey Farwell-2/+9
2017-08-05Update str::split_at_mut example to demonstrate mutability.Corey Farwell-6/+10
2017-08-04Indicate why str::{get,get_mut} examples return None.Corey Farwell-5/+15
2017-07-25std: Stabilize the `str_{mut,box}_extras` featureAlex Crichton-3/+3
Stabilizes * `<&mut str>::as_bytes_mut` * `<Box<str>>::into_boxed_bytes` * `std::str::from_boxed_utf8_unchecked` * `std::str::from_utf8_mut` * `std::str::from_utf8_unchecked_mut` Closes #41119
2017-07-25std: Stabilize `str_checked_slicing` featureAlex Crichton-8/+4
Stabilized * `<str>::get` * `<str>::get_mut` * `<str>::get_unchecked` * `<str>::get_unchecked_mut` Closes #39932
2017-06-13Merge crate `collections` into `alloc`Murarth-1/+1982
2017-04-24More methods for str boxes.Clar Charr-0/+21