Struct cxx::UniquePtr[][src]

#[repr(C)]
pub struct UniquePtr<T> where
    T: UniquePtrTarget
{ /* fields omitted */ }
Expand description

Binding to C++ std::unique_ptr<T, std::default_delete<T>>.

Implementations

Makes a new UniquePtr wrapping a null pointer.

Matches the behavior of default-constructing a std::unique_ptr.

Allocates memory on the heap and makes a UniquePtr pointing to it.

Checks whether the UniquePtr does not own an object.

This is the opposite of std::unique_ptr<T>::operator bool.

Returns a reference to the object owned by this UniquePtr if any, otherwise None.

Returns a mutable pinned reference to the object owned by this UniquePtr if any, otherwise None.

Returns a mutable pinned reference to the object owned by this UniquePtr.

Panics

Panics if the UniquePtr holds a null pointer.

Consumes the UniquePtr, releasing its ownership of the heap-allocated T.

Matches the behavior of std::unique_ptr<T>::release.

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

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.