Struct core::ptr::UniqueUnstable
[-]
[+]
[src]
pub struct Unique<T>(pub *mut T);
A wrapper around a raw *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).
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>
fn null() -> Unique<T>
Returns a null Unique.
unsafe fn offset(self, offset: int) -> *mut T
Return an (unsafe) pointer into the memory owned by self
.
Trait Implementations
impl<T: Send> Send for Unique<T>
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: Sync> Sync for Unique<T>
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.