| Age | Commit message (Collapse) | Author | Lines |
|
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).
|
|
This changes `self.ptr.as_mut()` with `get_mut_unchecked` which
does not use an intermediate reference. Arc<T> already handled this
case properly.
|
|
Trait implementations effectively can't be #[unstable].
|
|
Looks like it is no longer necessary, as uninit_array() can be used
instead in the few cases where it was needed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Replace lshift with multiply
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
|
|
const instead of multiple target_pointer_width checks.
|
|
Thanks, Amanieu
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
|
|
Link to `#capacity-and-reallocation` when using with_capacity
Follow up to https://github.com/rust-lang/rust/pull/76058#discussion_r479655750.
r? @pickfire
|
|
rename MaybeUninit slice methods
The `first` methods conceptually point to the whole slice, not just its first element, so rename them to be consistent with the raw ptr methods on ref-slices.
Also, do the equivalent of https://github.com/rust-lang/rust/pull/76047 for the slice reference getters, and make them part of https://github.com/rust-lang/rust/issues/63569 (so far they somehow had no tracking issue).
* first_ptr -> slice_as_ptr
* first_ptr_mut -> slice_as_mut_ptr
* slice_get_ref -> slice_assume_init_ref
* slice_get_mut -> slice_assume_init_mut
|
|
|
|
first_ptr -> slice_as_ptr
first_ptr_mut -> slice_as_mut_ptr
slice_get_ref -> slice_assume_init_ref
slice_get_mut -> slice_assume_init_mut
|
|
Link vec doc to & reference
It is not always obvious that people could see the docs for `&`
especially for beginners, it also helps learnability.
|
|
`impl Rc::new_cyclic`
References #75861
r? @Dylan-DPC
|
|
|
|
BTreeMap: introduce marker::ValMut and reserve Mut for unique access
The mutable BTreeMap iterators (apart from `DrainFilter`) are double-ended, meaning they have to rely on a front and a back handle that each represent a reference into the tree. Reserve a type category `marker::ValMut` for them, so that we guarantee that they cannot reach operations on handles with borrow type `marker::Mut`and that these operations can assume unique access to the tree.
Including #75195, benchmarks report no genuine change:
```
benchcmp old new --threshold 5
name old ns/iter new ns/iter diff ns/iter diff % speedup
btree::map::iter_100 3,333 3,023 -310 -9.30% x 1.10
btree::map::range_unbounded_vs_iter 36,624 31,569 -5,055 -13.80% x 1.16
```
r? @Mark-Simulacrum
|
|
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
|
|
This is very similar to the existing `Box<[T; N]>: TryFrom<Box<[T]>>`, but allows avoiding the `shrink_to_fit` if you have a vector and not a boxed slice.
|
|
|
|
|
|
The InPlaceIterable debug assert checks that the write pointer
did not advance beyond the read pointer. But TrustedRandomAccess
never advances the read pointer, thus triggering the assert.
Skip the assert if the source pointer did not change during iteration.
|
|
|
|
|
|
|
|
The optimization meant that every extend code path had to emit llvm
IR for from_iter and extend spec_extend, which likely impacts
compile times while only improving a few edge-cases
|
|
#[rustc_unsafe_specialization_marker]
|
|
|
|
|
|
|
|
into free functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private trait instead
|
|
|
|
|
|
# Conflicts:
# library/alloc/src/lib.rs
|
|
|
|
- it's an allocation optimization, so don't attempt to do it on ZSTs
- drop the tail of partially exhausted iters
|
|
|
|
|