summary refs log tree commit diff
path: root/library/alloc/src/vec/drain.rs
AgeCommit message (Collapse)AuthorLines
2022-05-11Rename `unsigned_offset_from` to `sub_ptr`Scott McMurray-1/+1
2022-05-11Add `unsigned_offset_from` on pointersScott McMurray-1/+1
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`. Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`. As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives. That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change. This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE. It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2021-12-11Fix zero-sized reference to deallocated memoryThe 8472-4/+6
fixes #91772
2021-12-09Use `*mut [T]` instead of `[MaybeUninit<T>]`The 8472-7/+5
2021-11-20document why we're not directly passing drop_ptr to drop_in_placeThe8472-0/+4
2021-11-20replace vec::Drain drop loops with drop_in_placeThe8472-14/+37
2021-10-15Add #[must_use] to remaining alloc functionsJohn Kugelman-0/+1
2021-10-11Add #[must_use] to as_type conversionsJohn Kugelman-0/+1
2020-12-29style: applying Rust styleC-5/+3
2020-12-29refactor: moving Drain into drain.rsC-0/+157