Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcm
Replace most uses of `pointer::offset` with `add` and `sub` As PR title says, it replaces `pointer::offset` in compiler and standard library with `pointer::add` and `pointer::sub`. This generally makes code cleaner, easier to grasp and removes (or, well, hides) integer casts. This is generally trivially correct, `.offset(-constant)` is just `.sub(constant)`, `.offset(usized as isize)` is just `.add(usized)`, etc. However in some cases we need to be careful with signs of things. r? ````@scottmcm```` _split off from #100746_
This commit is contained in:
commit
a45f69f27d
22 changed files with 57 additions and 57 deletions
|
@ -273,7 +273,7 @@ impl<D: Decoder, T: Decodable<D>> Decodable<D> for Vec<T> {
|
|||
unsafe {
|
||||
let ptr: *mut T = vec.as_mut_ptr();
|
||||
for i in 0..len {
|
||||
std::ptr::write(ptr.offset(i as isize), Decodable::decode(d));
|
||||
std::ptr::write(ptr.add(i), Decodable::decode(d));
|
||||
}
|
||||
vec.set_len(len);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue