[−][src]Struct smart_ptr::unique::Unique
Smart pointer, that owns and manages object via its pointer.
On Drop
it automatically disposes of pointer with provided deleter.
Useful in C FFI context.
Safety
If you use Deleter that relies on type information, you must guarantee that object was created using the same type as pointer, which points to it.
Which means you must guarantee that specified pointer is valid one and points to existing memory storage, which is already initialized.
Implementations
impl<T> Unique<T, DefaultDeleter>
[src]
pub fn boxed(val: T) -> Self
[src]
Creates new instance using global allocator
pub fn into_boxed(self) -> Box<T>
[src]
Converts ptr to box
impl<T, D: Default + Deleter> Unique<T, D>
[src]
pub unsafe fn new_default(ptr: *mut T) -> Self
[src]
pub unsafe fn from_ptr_default(ptr: *mut T) -> Option<Self>
[src]
Creates instance from raw pointer, checking if pointer is null.
Returns None
if pointer is null.
pub unsafe fn from_ptr_unchecked_default(ptr: *mut T) -> Self
[src]
Creates instance from raw pointer, without checking if pointer is null.
User must ensure that pointer is non-null
impl<T, D: Deleter> Unique<T, D>
[src]
pub unsafe fn new(ptr: *mut T, deleter: D) -> Self
[src]
pub unsafe fn from_ptr(ptr: *mut T, deleter: D) -> Option<Self>
[src]
Creates instance from raw pointer, checking if pointer is null.
Returns None
if pointer is null.
pub unsafe fn from_ptr_unchecked(ptr: *mut T, deleter: D) -> Self
[src]
Creates instance from raw pointer, without checking if pointer is null.
User must ensure that pointer is non-null
pub fn get(&self) -> *mut T
[src]
Gets underlying raw pointer.
pub fn as_ref(&self) -> &T
[src]
Gets reference to underlying data.
pub fn as_mut(&mut self) -> &mut T
[src]
Gets mutable reference to underlying data.
pub fn get_deleter(&mut self) -> &mut D
[src]
Gets underlying deleter
pub fn cast<N>(&self) -> *mut N
[src]
Retrieves pointer as of type
pub fn const_cast<N>(&self) -> *const N
[src]
Retrieves pointer as of type and const
pub fn swap(&mut self, other: &mut Self)
[src]
Swaps underlying pointers between instances
pub fn release(self) -> NonNull<T>
[src]
Releases the ownership and returns raw pointer, without dropping it.
Trait Implementations
impl<T, D: Deleter> Debug for Unique<T, D>
[src]
impl<T, D: Deleter> Deref for Unique<T, D>
[src]
impl<T, D: Deleter> DerefMut for Unique<T, D>
[src]
impl<T, D: Deleter> Drop for Unique<T, D>
[src]
impl<T, D: Deleter> Hash for Unique<T, D>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T, D: Deleter> Pointer for Unique<T, D>
[src]
impl<T: Send, D: Deleter + Send> Send for Unique<T, D>
[src]
impl<T: Sync, D: Deleter + Sync> Sync for Unique<T, D>
[src]
impl<T: Unpin, D: Deleter + Unpin> Unpin for Unique<T, D>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,