mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Refine [Arc/Rc]::from_raw() docs
This commit is contained in:
parent
becebf3106
commit
b4c96a9199
@ -570,16 +570,24 @@ impl<T: ?Sized> Rc<T> {
|
|||||||
ptr
|
ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs an `Rc` from a raw pointer.
|
/// Constructs an `Rc<T>` from a raw pointer.
|
||||||
///
|
///
|
||||||
/// The raw pointer must have been previously returned by a call to a
|
/// The raw pointer must have been previously returned by a call to
|
||||||
/// [`Rc::into_raw`][into_raw] using the same `T`.
|
/// [`Rc<U>::into_raw`][into_raw] where `U` must have the same size
|
||||||
|
/// and alignment as `T`. This is trivially true if `U` is `T`.
|
||||||
|
/// Note that if `U` is not `T` but has the same size and alignment, this is
|
||||||
|
/// basically like transmuting references of different types. See
|
||||||
|
/// [`mem::transmute`][transmute] for more information on what
|
||||||
|
/// restrictions apply in this case.
|
||||||
|
///
|
||||||
|
/// The user of `from_raw` has to make sure a specific value of `T` is only
|
||||||
|
/// dropped once.
|
||||||
///
|
///
|
||||||
/// This function is unsafe because improper use may lead to memory unsafety,
|
/// This function is unsafe because improper use may lead to memory unsafety,
|
||||||
/// even if `T` is never accessed. For example, a double-free may occur if the function is
|
/// even if the returned `Rc<T>` is never accessed.
|
||||||
/// called twice on the same raw pointer.
|
|
||||||
///
|
///
|
||||||
/// [into_raw]: struct.Rc.html#method.into_raw
|
/// [into_raw]: struct.Rc.html#method.into_raw
|
||||||
|
/// [transmute]: ../../std/mem/fn.transmute.html
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -550,16 +550,24 @@ impl<T: ?Sized> Arc<T> {
|
|||||||
ptr
|
ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs an `Arc` from a raw pointer.
|
/// Constructs an `Arc<T>` from a raw pointer.
|
||||||
///
|
///
|
||||||
/// The raw pointer must have been previously returned by a call to a
|
/// The raw pointer must have been previously returned by a call to
|
||||||
/// [`Arc::into_raw`][into_raw], using the same `T`.
|
/// [`Arc<U>::into_raw`][into_raw] where `U` must have the same size and
|
||||||
|
/// alignment as `T`. This is trivially true if `U` is `T`.
|
||||||
|
/// Note that if `U` is not `T` but has the same size and alignment, this is
|
||||||
|
/// basically like transmuting references of different types. See
|
||||||
|
/// [`mem::transmute`][transmute] for more information on what
|
||||||
|
/// restrictions apply in this case.
|
||||||
|
///
|
||||||
|
/// The user of `from_raw` has to make sure a specific value of `T` is only
|
||||||
|
/// dropped once.
|
||||||
///
|
///
|
||||||
/// This function is unsafe because improper use may lead to memory unsafety,
|
/// This function is unsafe because improper use may lead to memory unsafety,
|
||||||
/// even if `T` is never accessed. For example, a double-free may occur if the function is
|
/// even if the returned `Arc<T>` is never accessed.
|
||||||
/// called twice on the same raw pointer.
|
|
||||||
///
|
///
|
||||||
/// [into_raw]: struct.Arc.html#method.into_raw
|
/// [into_raw]: struct.Arc.html#method.into_raw
|
||||||
|
/// [transmute]: ../../std/mem/fn.transmute.html
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user