Line 129:
self.ptr = unsafe { arith_offset(self.ptr as *const i8, 1) as *mut T };
self.ptr
is *const T
and arithm_offset()
returns *const i8
.
Why is the *const i8
cast to *mut T
instead of *const T
?
Line 129:
self.ptr = unsafe { arith_offset(self.ptr as *const i8, 1) as *mut T };
self.ptr
is *const T
and arithm_offset()
returns *const i8
.
Why is the *const i8
cast to *mut T
instead of *const T
?
It has been changed here:
so I guess as_mut_slice
needs *mut T
, so the rest of the code had to adjust. But end
hasn't been changed to *mut
, which is why it's cast back and forth.
Wow, thx. That is a pretty old commit. as_mut_slice
now takes &mut self
instead of &self
and ptr
becomes const ptr again. So the original casting to *mut T
becomes unnecessary. Guess developers forget changing it back. Nevertheless, it just looks odd and does not hurt anything.