-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
For example
pub unsafe fn ptr_0(&mut self) -> *mut String {
let inner = self.inner.as_mut_ptr();
&raw mut (*inner).a
}A reference in Rust gurantees that the memory is initialized. You need to use addr_of_mut to correctly model this.
Somewhat unrleated but I thought I'd mention it.
let ptr =
&self as *const OrangeBuilder<AUnset, FieldB> as
*const OrangeBuilder<ASet, FieldB>;
::core::mem::forget(self);
unsafe { ptr.read() }That looks a lot like transmute. Is there a specific reason not to use transmute here? Also this is UB too, the docs for mem::forget
Any resources the value manages, such as heap memory or a file handle, will linger forever in an unreachable state. However, it does not guarantee that pointers to this memory will remain valid.
Metadata
Metadata
Assignees
Labels
No labels