DropGuard

Struct DropGuard 

Source
pub struct DropGuard<T: DropIn, A: Allocator> { /* private fields */ }
Expand description

A temporary guard object that will DropIn the value using the associated alloc on Drop.

Implementations§

Source§

impl<T: DropIn, A: Allocator> DropGuard<T, A>

Source

pub unsafe fn new(value: T, alloc: A) -> Self

Create a DropGuard to avoid leaking value in the event of errors.

§Safety

alloc MUST be the correct Allocator instance to drop_in value.

Source

pub fn split(self) -> (ManuallyDrop<T>, A)

Split the DropGuard into its constituent parts. The caller is taking responsibility for drop_in T in A.

Source

pub fn map<U: DropIn, F>(self, f: F) -> DropGuard<U, A>
where F: FnOnce(T) -> U,

Apply a function f to the inner value. Note that the value will not be dropped by this function.

Source

pub fn into_inner(self) -> ManuallyDrop<T>

Unwrap the inner value. This is intended to transfer ownership into the permanent data structure.

Source

pub fn alloc(&self) -> &A

Unwrap the allocator. This is intended to transfer ownership into the permanent data structure.

Trait Implementations§

Source§

impl<T: Debug + DropIn, A: Debug + Allocator> Debug for DropGuard<T, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: DropIn, A: Allocator> Deref for DropGuard<T, A>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: DropIn, A: Allocator> DerefMut for DropGuard<T, A>

Source§

fn deref_mut(&mut self) -> &mut T

Mutably dereferences the value.
Source§

impl<T: DropIn, A: Allocator> Drop for DropGuard<T, A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T, A> Freeze for DropGuard<T, A>
where A: Freeze, T: Freeze,

§

impl<T, A> RefUnwindSafe for DropGuard<T, A>

§

impl<T, A> Send for DropGuard<T, A>
where A: Send, T: Send,

§

impl<T, A> Sync for DropGuard<T, A>
where A: Sync, T: Sync,

§

impl<T, A> Unpin for DropGuard<T, A>
where A: Unpin, T: Unpin,

§

impl<T, A> UnwindSafe for DropGuard<T, A>
where A: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.