[−][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 provided pointer was created using the same type as pointer
Methods
impl<T, D: Default + Deleter> Unique<T, D>
[src]
pub fn new_default(ptr: *mut T) -> Self
[src]
pub 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.
impl<T, D: Deleter> Unique<T, D>
[src]
pub fn new(ptr: *mut T, deleter: D) -> Self
[src]
pub 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 fn as_ptr(&self) -> *mut T
[src]
Gets underlying raw pointer.
pub fn as_ref(&self) -> &T
[src]
Gets reference to underlying object
pub fn as_mut(&self) -> &mut T
[src]
Gets mutable reference to underlying object
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> Drop for Unique<T, D>
[src]
impl<T: Unpin, D: Deleter + Unpin> Unpin 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, D: Deleter> Pointer for Unique<T, D>
[src]
Blanket Implementations
impl<T> From<T> for T
[src]
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> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,