logo
Expand description

Rename *T to *const T.

Note

RustC
*mut TT*
*const Tconst T*

Valid coercion

&'a T ==> *const T&'a mut T ==> *mut T
rustcthe memory will remain valid for the lifetime 'a and the memory will be immutable up to memory stored in Unsafe<U>the memory will stay valid during ’a and that the memory will not be accessed during 'a, and will consume the &'a mut T during the coercion
codethe pointer is only dereferenced in the lifetime 'athe unsafe pointer is only dereferenced in the lifetime 'a, and that the memory is “valid again” after 'a

Valid cast

*mut T ==> &’a mut T*const T ==> &'a T
the memory is initialized to start out with and that nobody will access the memory during 'a except for the converted pointerthe memory is initialized to start out with and that nobody will write to the pointer during 'a except for memory within Unsafe<U>

RFC: 0086-const-unsafe-pointers