Apply #66379 to *mut T
as_ref
This commit is contained in:
parent
f9a3086363
commit
40df8fd0fa
@ -47,17 +47,22 @@ pub const fn cast<U>(self) -> *mut U {
|
|||||||
/// operation because the returned value could be pointing to invalid
|
/// operation because the returned value could be pointing to invalid
|
||||||
/// memory.
|
/// memory.
|
||||||
///
|
///
|
||||||
/// When calling this method, you have to ensure that if the pointer is
|
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
|
||||||
/// non-NULL, then it is properly aligned, dereferenceable (for the whole
|
/// all of the following is true:
|
||||||
/// size of `T`) and points to an initialized instance of `T`. This applies
|
/// - it is properly aligned
|
||||||
/// even if the result of this method is unused!
|
/// - it must point to an initialized instance of T; in particular, the pointer must be
|
||||||
|
/// "dereferencable" in the sense defined [here].
|
||||||
|
///
|
||||||
|
/// This applies even if the result of this method is unused!
|
||||||
/// (The part about being initialized is not yet fully decided, but until
|
/// (The part about being initialized is not yet fully decided, but until
|
||||||
/// it is, the only safe approach is to ensure that they are indeed initialized.)
|
/// it is, the only safe approach is to ensure that they are indeed initialized.)
|
||||||
///
|
///
|
||||||
/// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
|
/// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
|
||||||
/// not necessarily reflect the actual lifetime of the data. It is up to the
|
/// not necessarily reflect the actual lifetime of the data. *You* must enforce
|
||||||
/// caller to ensure that for the duration of this lifetime, the memory this
|
/// Rust's aliasing rules. In particular, for the duration of this lifetime,
|
||||||
/// pointer points to does not get written to outside of `UnsafeCell<U>`.
|
/// the memory the pointer points to must not get mutated (except inside `UnsafeCell`).
|
||||||
|
///
|
||||||
|
/// [here]: crate::ptr#safety
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user