dylni
b96063cf47
Fix soundness issue for replace_range
and range
2021-01-18 22:14:38 -05:00
Konrad Borowski
9e779986aa
Add "length" as doc alias to len methods
2020-12-28 09:13:46 +01:00
Corey Farwell
33ae62c3d7
Clarify that String::split_at takes a byte index.
2020-12-09 13:17:54 -05:00
Giacomo Stevanato
e83666f45e
Prevent String::retain from creating non-utf8 strings when abusing panic
2020-10-29 11:58:12 +01:00
Camelid
13bc087a73
Clean up lib docs
2020-10-22 10:36:35 -07:00
bors
187b8771dc
Auto merge of #76885 - dylni:move-slice-check-range-to-range-bounds, r=KodrAus
...
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-18 18:50:43 +00:00
Mara Bos
0b062887db
Remove shrink_to_fit from default ToString::to_string implementation.
...
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2020-10-16 11:15:12 +02:00
Ralf Jung
46bb884cf3
Rollup merge of #76525 - fusion-engineering-forks:string-drain, r=dtolnay
...
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-19 11:47:47 +02:00
Mara Bos
15eb638dc9
Add tracking issue number for string_drain_as_str.
2020-09-19 08:23:23 +02:00
dylni
f055b0bb08
Rename method to assert_len
2020-09-18 13:55:03 -04:00
dylni
1ff7da6551
Move slice::check_range
to RangeBounds
2020-09-18 12:17:51 -04:00
Ralf Jung
c528d24196
fix slice::check_range aliasing problems
2020-09-15 23:14:41 +02:00
Mara Bos
829019d404
Disable AsRef implementations for String's Drain.
...
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-09 19:57:57 +02:00
Mara Bos
f2a32909e0
Mark AsRef impls for String's Drain as stable.
...
Trait implementations effectively can't be #[unstable].
2020-09-09 19:10:06 +02:00
Mara Bos
f5bb523e94
Add AsRef<[u8]> for String's Drain.
2020-09-09 18:07:27 +02:00
Mara Bos
673284058b
Show remaining data in string::Drain's Debug impl.
2020-09-09 17:50:55 +02:00
Mara Bos
daa62d9081
Add as_str() and AsRef to string::Drain.
2020-09-09 17:50:55 +02:00
bors
ef55a0a92f
Auto merge of #75207 - dylni:add-slice-check-range, r=KodrAus
...
Add `slice::check_range`
This method is useful for [`RangeBounds`] parameters. It's even been [rewritten](22ee68dc58/src/librustc_data_structures/sorted_map.rs (L214)
) [many](22ee68dc58/library/alloc/src/vec.rs (L1299)
) [times](22ee68dc58/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-09-04 12:21:43 +00:00
Joshua Nelson
373432e47f
Convert from str -> prim@str for alloc
2020-08-23 22:40:20 -04:00
dylni
d04e6b8de5
Replace ad hoc implementations with slice::check_range
2020-08-16 21:47:12 -04:00
Lzu Tao
27e1b0632c
Explain why inline default ToString impl
2020-07-29 07:38:06 +00:00
mark
2c31b45ae8
mv std libs to library/
2020-07-27 19:51:13 -05:00