pub fn as_mut_ptr(&mut self) -> *mut T {
// We shadow the slice method of the same name to avoid going through
// `deref_mut`, which creates an intermediate reference.
let ptr = self.buf.ptr();
unsafe {
assume(!ptr.is_null());
}
ptr
}
The conversion process is entirely pointer and does not involve any notion of reference.
These methods rely too much on the internal implementation of the library, which is not a big problem if it is a standard library, but it is dangerous to use third-party libraries in this way, so this PR removes all use cases
Uninitialized memory that does not have to be read or referenced, otherwise it is UB, but it can be converted as pointer to use.
But this behavior is difficult to delimit, especially when the type itself does not provide a corresponding method.
The correct behavior is for example
Vec::as_mut_ptr()
:The conversion process is entirely pointer and does not involve any notion of reference.
ByteMut::uninit_slice
ByteMut::as_slice_mut
These methods rely too much on the internal implementation of the library, which is not a big problem if it is a standard library, but it is dangerous to use third-party libraries in this way, so this PR removes all use cases