Rollup merge of #100819 - WaffleLapkin:use_ptr_byte_methods, r=scottmcm
Make use of `[wrapping_]byte_{add,sub}` These new methods trivially replace old `.cast().wrapping_offset().cast()` & similar code. Note that [`arith_offset`](https://doc.rust-lang.org/std/intrinsics/fn.arith_offset.html) and `wrapping_offset` are the same thing. r? ``@scottmcm`` _split off from #100746_
This commit is contained in:
commit
395ce34a95
10 changed files with 17 additions and 18 deletions
|
@ -255,7 +255,7 @@ impl<T: ?Sized> *mut T {
|
|||
let offset = dest_addr.wrapping_sub(self_addr);
|
||||
|
||||
// This is the canonical desugarring of this operation
|
||||
self.cast::<u8>().wrapping_offset(offset).cast::<T>()
|
||||
self.wrapping_byte_offset(offset)
|
||||
}
|
||||
|
||||
/// Creates a new pointer by mapping `self`'s address to a new one.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue