Struct std::ptr::Unique
[−]
[src]
pub struct Unique<T> where T: ?Sized { /* fields omitted */ }
🔬 This is a nightly-only experimental API. (unique
)
needs an RFC to flesh out design
A wrapper around a raw non-null *mut T
that indicates that the possessor
of this wrapper owns the referent. This in turn implies that the
Unique<T>
is Send
/Sync
if T
is Send
/Sync
, unlike a raw
*mut T
(which conveys no particular ownership semantics). It
also implies that the referent of the pointer should not be
modified without a unique path to the Unique
reference. Useful
for building abstractions like Vec<T>
or Box<T>
, which
internally use raw pointers to manage the memory that they own.
Methods
impl<T> Unique<T> where T: ?Sized
[src]
const unsafe fn new(ptr: *mut T) -> Unique<T>
unique
)unsafe fn get(&self) -> &T
unique
)Dereferences the content.
unsafe fn get_mut(&mut self) -> &mut T
unique
)Mutably dereferences the content.
Trait Implementations
impl<T> Deref for Unique<T> where T: ?Sized
[src]
type Target = *mut T
The resulting type after dereferencing
fn deref(&self) -> &*mut T
The method called to dereference a value
impl<T> Sync for Unique<T> where T: Sync + ?Sized
[src]
Unique
pointers are Sync
if T
is Sync
because the data they
reference is unaliased. Note that this aliasing invariant is
unenforced by the type system; the abstraction using the
Unique
must enforce it.
impl<T> Send for Unique<T> where T: Send + ?Sized
[src]
Unique
pointers are Send
if T
is Send
because the data they
reference is unaliased. Note that this aliasing invariant is
unenforced by the type system; the abstraction using the
Unique
must enforce it.
impl<T, U> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> + ?Sized,
U: ?Sized
[src]
U: ?Sized