about summary refs log tree commit diff
path: root/src/liballoc/str.rs
AgeCommit message (Collapse)AuthorLines
2019-04-22Remove double trailing newlinesvarkor-1/+0
2019-04-12Re-export core::str::{EscapeDebug, EscapeDefault, EscapeUnicode} in stdLzu Tao-0/+2
2019-02-12Move str::escape_* to libcoreSimon Sapin-118/+0
2019-02-12Stabilize str::escape_* methodsSimon Sapin-13/+7
FCP: https://github.com/rust-lang/rust/issues/27791#issuecomment-376864727
2019-02-12New return types for str::escape_* that impl Display and Iterator<char>Simon Sapin-12/+96
As FCP’ed in the tracking issue: https://github.com/rust-lang/rust/issues/27791#issuecomment-376864727
2019-02-03Auto merge of #58081 - Centril:liballoc-2018, r=oli-obkbors-7/+7
Transition liballoc to Rust 2018 This transitions liballoc to Rust 2018 edition and applies relevant idiom lints. I also did a small bit of drive-by cleanup along the way. r? @oli-obk I started with liballoc since it seemed easiest. In particular, adding `edition = "2018"` to libcore gave me way too many errors due to stdsimd. Ideally we should be able to continue this crate-by-crate until all crates use 2018.
2019-02-03liballoc: revert nested imports style changes.Mazdak Farrokhzad-20/+14
2019-02-02liballoc: prefer imports of borrow from libcore.Mazdak Farrokhzad-1/+2
2019-02-02liballoc: refactor & fix some imports.Mazdak Farrokhzad-14/+19
2019-02-02liballoc: cargo check passes on 2018Mazdak Farrokhzad-5/+5
2019-02-01Stabilize split_ascii_whitespaceSimon Sapin-1/+1
Tracking issue FCP to merge: https://github.com/rust-lang/rust/issues/48656#issuecomment-442372750
2018-12-25Remove licensesMark Rousskov-10/+0
2018-09-27liballoc: mark str.to_owned() and String::from(&str) as #[inline].Matthias Krüger-0/+1
Fixes #53681
2018-09-20std: Check for overflow in `str::repeat`Alex Crichton-0/+13
This commit fixes a buffer overflow issue in the standard library discovered by Scott McMurray where if a large number was passed to `str::repeat` it may cause and out of bounds write to the buffer of a `Vec`. This bug was accidentally introduced in #48657 when optimizing the `str::repeat` function. The bug affects stable Rust releases 1.26.0 to 1.29.0. We plan on backporting this fix to create a 1.29.1 release, and the 1.30.0 release onwards will include this fix. The fix in this commit is to introduce a deterministic panic in the case of capacity overflow. When repeating a slice where the resulting length is larger than the address space, there’s no way it can succeed anyway! The standard library and surrounding libraries were briefly checked to see if there were othere instances of preallocating a vector with a calculation that may overflow. No instances of this bug (out of bounds write due to a calculation overflow) were found at this time. Note that this commit is the first steps towards fixing this issue, we'll be making a formal post to the Rust security list once these commits have been merged.
2018-08-22docs: std::string::String.repeat(): slightly rephrase to be more in-line ↵Matthias Krüger-1/+1
with other descriptions. add ticks around a few keywords in other descriptions.
2018-07-22Rollup merge of #51807 - newpavlov:deprecate_str_slice, r=alexcrichtonkennytm-4/+4
Deprecation of str::slice_unchecked(_mut) Closes #51715 I am not sure if 1.28.0 or 1.29.0 should be used for deprecation version, for now it's 1.28.0. Additionally I've replaced `slice_unchecked` uses with `get_unchecked`. The only places where this method is still used are `src/liballoc/tests/str.rs` and `src/liballoc/tests/str.rs`.
2018-07-06Handle array manually in string case conversion methodsPazzaz-2/+27
2018-06-29Move some alloc crate top-level items to a new alloc::collections moduleSimon Sapin-1/+0
This matches std::collections
2018-06-27Add str::split_ascii_whitespace.Clar Charr-0/+2
2018-06-26Deprecation of str::slice_uncheked(_mut)newpavlov-4/+4
2018-06-01incorporate changes from code reviewEmerentius-27/+33
further reduce unsafe fn calls reduce right drift assert! sufficient capacity
2018-06-01compacts join codeEmerentius-30/+14
2018-06-01optimize joining and concatenation for slicesEmerentius-36/+102
for both Vec<T> and String - eliminates the boolean first flag in fn join() for String only - eliminates repeated bounds checks in join(), concat() - adds fast paths for small string separators up to a len of 4 bytes
2018-05-21Avoid counting characters and add explanatory comment to testvarkor-1/+7
2018-05-21Only escape extended grapheme characters in the first positionvarkor-1/+4
2018-05-17Switch to 1.26 bootstrap compilerMark Simulacrum-6/+1
2018-05-09move See also links to topMichael Lamparski-2/+2
2018-05-07Add explanation for #[must_use] on string replace methodsManish Goregaokar-2/+4
2018-04-26Rollup merge of #50177 - matthiaskrgr:std_std_replacen__must_use, r=oli-obkGuillaume Gomez-0/+2
mark std::str::replace(,n) as #[must_use] let x = "a b c c"; x.replacen("c", "d", 2"); might not do what people might think it does.
2018-04-24Auto merge of #48999 - GuillaumeGomez:add-repeat-on-slice, r=Kimundibors-53/+1
Add repeat method on slice Fixes #48784.
2018-04-23mark std::str::replacen and std::str::replace as #[must_use].Matthias Krüger-0/+2
2018-04-21Replace StrExt with inherent str methods in libcoreSimon Sapin-1724/+7
2018-04-19Tweak some stabilizations in libstdAlex Crichton-42/+0
This commit tweaks a few stable APIs in the `beta` branch before they hit stable. The `str::is_whitespace` and `str::is_alphanumeric` functions were deleted (added in #49381, issue at #49657). The `and_modify` APIs added in #44734 were altered to take a `FnOnce` closure rather than a `FnMut` closure. Closes #49581 Closes #49657
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