Enum zerodrop::ZeroDropCow [] [src]

pub enum ZeroDropCow<'a, T: Copy + 'a> {
    Borrowed(&'a T),
    Boxed(Box<T>),
}

Zeroing drop copy-on-write type for Copy types.

Assuming T: Copy, a ZeroDrop<T> wraps a Box<T> and zeros it when dropped. Unlike Cow, we must use Box because LLVM moves data wildly around the stack.

Variants

Borrowed data.

Boxed data.

Methods

impl<'a, T> ZeroDropCow<'a, T> where T: 'a + Copy
[src]

Insecure as t likely gets placed on the stack

Secure but unsafe

Create a ZeroDrop<T> for a T: Copy that borrows its argument.

Create a ZeroDrop<T> for a T: Copy consisting of a Box<T> that will be zeroed when dropped. Use ZeroDrop instead normally.

Convert a ZeroDrowCow into a ZeroDrop, copying if still borrowed.

Trait Implementations

impl<'a, T> Drop for ZeroDropCow<'a, T> where T: 'a + Copy
[src]

Zero a ZeroDrop<T> when dropped.

A method called when the value goes out of scope. Read more

impl<'a, T> Default for ZeroDropCow<'a, T> where T: 'a + Copy + Default
[src]

Creates a boxed ZeroDropCow<'a, T> with the default value for the contained owned value.

impl<'a, T> Clone for ZeroDropCow<'a, T> where T: 'a + Copy
[src]

Reborrow a Borrowed or Clone a Boxed

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a, T> Deref for ZeroDropCow<'a, T> where T: 'a + Copy
[src]

Delegate Deref to Borrowed or Boxed.

The resulting type after dereferencing

The method called to dereference a value

impl<'a, T, U> AsRef<U> for ZeroDropCow<'a, T> where T: 'a + Copy + AsRef<U>
[src]

Delegate AsRef<_> to Borrowed or Boxed.

Performs the conversion.

impl<'a, T> Borrow<T> for ZeroDropCow<'a, T> where T: 'a + Copy
[src]

Delegate Borrow<T> to Borrowed or Boxed.

Immutably borrows from an owned value. Read more