Struct core::ptr::Unique
[−]
[src]
pub struct Unique<T: ?Sized> { // some fields omitted }
: needs an RFC to flesh out design
A wrapper around a raw *mut T
`*mut Tthat indicates that the possessor of this wrapper owns the referent. This in turn implies that the
Uniqueis
` is Send
`Send/
`/Sync
`Syncif
` if T
`Tis
` is Send
`Send/
`/Sync
`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
Uniquereference. Useful for building abstractions like
Vecor
` or Box<T>
`Box
Methods
impl<T: ?Sized> Unique<T>
unsafe fn new(ptr: *mut T) -> Unique<T>
Creates a new Unique
`Unique`.
unsafe fn get(&self) -> &T
Dereferences the content.
unsafe fn get_mut(&mut self) -> &mut T
Mutably dereferences the content.
Trait Implementations
impl<T: Send + ?Sized> Send for Unique<T>
Unique
`Uniquepointers are
Sendif
` if T
`Tis
` is Send
`Sendbecause 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 + ?Sized> Sync for Unique<T>
Unique
`Uniquepointers are
Syncif
` if T
`Tis
` is Sync
`Syncbecause 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.