about summary refs log tree commit diff
path: root/library/alloc/src/string.rs
AgeCommit message (Collapse)AuthorLines
2021-01-26shrink_to shouldn't panic on len greater than capacityThom Wiggers-2/+1
2021-01-22Add doc aliases for memory allocationsYoshua Wuyts-0/+2
- Vec::with_capacity / Box::new -> alloc + malloc - Box::new_zeroed -> calloc - Vec::{reserve,reserve_exact,try_reserve_exact,shrink_to_fit,shrink_to} -> realloc
2021-01-18Fix soundness issue for `replace_range` and `range`dylni-3/+10
2020-12-28Add "length" as doc alias to len methodsKonrad Borowski-0/+1
2020-12-09Clarify that String::split_at takes a byte index.Corey Farwell-1/+1
2020-10-29Prevent String::retain from creating non-utf8 strings when abusing panicGiacomo Stevanato-4/+6
2020-10-22Clean up lib docsCamelid-9/+10
2020-10-18Auto merge of #76885 - dylni:move-slice-check-range-to-range-bounds, r=KodrAusbors-3/+2
Move `slice::check_range` to `RangeBounds` Since this method doesn't take a slice anymore (#76662), it makes more sense to define it on `RangeBounds`. Questions: - Should the new method be `assert_len` or `assert_length`?
2020-10-16Remove shrink_to_fit from default ToString::to_string implementation.Mara Bos-1/+0
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2020-09-19Rollup merge of #76525 - fusion-engineering-forks:string-drain, r=dtolnayRalf Jung-1/+35
Add as_str() to string::Drain. Vec's Drain recently [had its `.as_slice()` stabilized](https://github.com/rust-lang/rust/pull/72584), but String's Drain was still missing the analogous `.as_str()`. This adds that. Also improves the Debug implementation, which now shows the remaining data instead of just `"Drain { .. }"`.
2020-09-19Add tracking issue number for string_drain_as_str.Mara Bos-3/+3
2020-09-18Rename method to `assert_len`dylni-2/+2
2020-09-18Move `slice::check_range` to `RangeBounds`dylni-3/+2
2020-09-15fix slice::check_range aliasing problemsRalf Jung-1/+2
2020-09-09Disable AsRef implementations for String's Drain.Mara Bos-14/+15
Since trait implementations cannot be unstable, we should only add them when the as_str feature gets stabilized. Until then, only `.as_str()` is available (behind a feature gate).
2020-09-09Mark AsRef impls for String's Drain as stable.Mara Bos-2/+2
Trait implementations effectively can't be #[unstable].
2020-09-09Add AsRef<[u8]> for String's Drain.Mara Bos-0/+7
2020-09-09Show remaining data in string::Drain's Debug impl.Mara Bos-1/+1
2020-09-09Add as_str() and AsRef to string::Drain.Mara Bos-0/+26
2020-09-04Auto merge of #75207 - dylni:add-slice-check-range, r=KodrAusbors-14/+6
Add `slice::check_range` This method is useful for [`RangeBounds`] parameters. It's even been [rewritten](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/src/librustc_data_structures/sorted_map.rs#L214) [many](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/library/alloc/src/vec.rs#L1299) [times](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/library/core/src/slice/mod.rs#L2441) in the standard library, sometimes assuming that the bounds won't be [`usize::MAX`]. For example, [`Vec::drain`] creates an empty iterator when [`usize::MAX`] is used as an inclusive end bound: ```rust assert!(vec![1].drain(..=usize::max_value()).eq(iter::empty())); ``` If this PR is merged, I'll create another to use it for those methods. [`RangeBounds`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html [`usize::MAX`]: https://doc.rust-lang.org/std/primitive.usize.html#associatedconstant.MAX [`Vec::drain`]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.drain
2020-08-23Convert from str -> prim@str for `alloc`Joshua Nelson-5/+7
2020-08-16Replace ad hoc implementations with `slice::check_range`dylni-14/+6
2020-07-29Explain why inline default ToString implLzu Tao-0/+3
2020-07-27mv std libs to library/mark-0/+2504