Struct maybe_box::MaybeBox [] [src]

pub struct MaybeBox<T> { /* fields omitted */ }

Hold a value of type T in the space for a usize, only boxing it if necessary. This can be a useful optimization when dealing with C APIs that allow you to pass around some arbitrary void *-sized piece of data.

This type is guranteed to be the same size as a usize.

Methods

impl<T> MaybeBox<T>
[src]

Wrap a T into a MaybeBox<T>. This will allocate if size_of::<T>() > size_of::<usize>().

Consume the MaybeBox<T> and return the inner T.

Consume the MaybeBox<T> and return the inner T, possibly boxed (if it was already).

This may be more efficient than calling into_inner and then boxing the returned value.

Trait Implementations

impl<T> Drop for MaybeBox<T>
[src]

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

impl<T> From<T> for MaybeBox<T>
[src]

Performs the conversion.

impl<T> Deref for MaybeBox<T>
[src]

The resulting type after dereferencing

The method called to dereference a value

impl<T> DerefMut for MaybeBox<T>
[src]

The method called to mutably dereference a value

impl<T: Debug> Debug for MaybeBox<T>
[src]

Formats the value using the given formatter.

impl<U, T: PartialEq<U>> PartialEq<MaybeBox<U>> for MaybeBox<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Eq> Eq for MaybeBox<T>
[src]

impl<T: Hash> Hash for MaybeBox<T>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more