[−][src]Struct cxx::UniquePtr
Binding to C++ std::unique_ptr<T, std::default_delete<T>>
.
Methods
impl<T> UniquePtr<T> where
T: UniquePtrTarget,
[src]
T: UniquePtrTarget,
pub fn null() -> Self
[src]
Makes a new UniquePtr wrapping a null pointer.
Matches the behavior of default-constructing a std::unique_ptr.
pub fn new(value: T) -> Self
[src]
Allocates memory on the heap and makes a UniquePtr pointing to it.
pub fn is_null(&self) -> bool
[src]
Checks whether the UniquePtr does not own an object.
This is the opposite of std::unique_ptr<T>::operator bool.
pub fn as_ref(&self) -> Option<&T>
[src]
Returns a reference to the object owned by this UniquePtr if any, otherwise None.
pub fn as_mut(&mut self) -> Option<&mut T>
[src]
Returns a mutable reference to the object owned by this UniquePtr if any, otherwise None.
pub fn into_raw(self) -> *mut T
[src]
Consumes the UniquePtr, releasing its ownership of the heap-allocated T.
Matches the behavior of std::unique_ptr<T>::release.
pub unsafe fn from_raw(raw: *mut T) -> Self
[src]
Constructs a UniquePtr retaking ownership of a pointer previously
obtained from into_raw
.
Safety
This function is unsafe because improper use may lead to memory problems. For example a double-free may occur if the function is called twice on the same raw pointer.
Trait Implementations
impl<T> Debug for UniquePtr<T> where
T: Debug + UniquePtrTarget,
[src]
T: Debug + UniquePtrTarget,
impl<T> Deref for UniquePtr<T> where
T: UniquePtrTarget,
[src]
T: UniquePtrTarget,
impl<T> DerefMut for UniquePtr<T> where
T: UniquePtrTarget,
[src]
T: UniquePtrTarget,
impl<T> Display for UniquePtr<T> where
T: Display + UniquePtrTarget,
[src]
T: Display + UniquePtrTarget,
impl<T> Drop for UniquePtr<T> where
T: UniquePtrTarget,
[src]
T: UniquePtrTarget,
impl<T> Send for UniquePtr<T> where
T: Send + UniquePtrTarget,
[src]
T: Send + UniquePtrTarget,
impl<T> Sync for UniquePtr<T> where
T: Sync + UniquePtrTarget,
[src]
T: Sync + UniquePtrTarget,
Auto Trait Implementations
impl<T> RefUnwindSafe for UniquePtr<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Unpin for UniquePtr<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for UniquePtr<T> where
T: UnwindSafe,
T: UnwindSafe,
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,