Struct efficient_enum::option::EfficientOption [] [src]

pub struct EfficientOption<A, B = (), TM = TagMSB>(_, _)
where
    A: TaggableValue<TM, One>
;

An option type similar to Option<(A, B)>, but where no extra data is used. Instead, some of the space in A is used to "tag the union".

The one true downside is that it is impossible to get &A from &EfficientOption. The reason for this is that doing so would expose the private tag info.

Methods

impl<TM, A, B> EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

Constructs a new EfficientOption

Constructs a new EfficientOption

Constructs a new EfficientOption

Constructs an empty EfficientOption

Constructs an EfficientOption from an A value

Constructs an EfficientOption from an A value

Constructs an EfficientOption from an B value

Clones the A value if one exists

Clones the B value if one exists

Gets references to both the A and B values if they exist

Gets a reference to the A value if one exists

Gets a reference to the B value if one exists

Gets references to both the A and B values by assuming they exist

Gets a reference to the A value by assuming one exists

Gets a reference to the A value by assuming one exists

Gets a reference to the A value and a mutable reference to the B value if they exist

Gets mutable a reference to the B value if one exists

Gets a reference to the A value and a mutable reference to the B value by assuming they exist

Gets mutable a reference to the B value by assuming one exists

Returns an EfficientOptionInnerSome if the option is a Some value, returns an EfficientOptionInnerNone otherwise.

Returns an EfficientOptionInnerSome.

Returns an EfficientOptionInnerSome.

Destructures an EfficientOption

Destructures an EfficientOption into the A value if one exists

Destructures an EfficientOption into the B value if one exists

Destructures an EfficientOption

Destructures an EfficientOption into the A value by assuming one exists

Destructures an EfficientOption into the B value by assuming one exists

Takes the value out of the option, leaving a None in its place.

Takes both values out of the option, leaving a None in its place. The version only returns the A value

Takes both values out of the option, leaving a None in its place. The version only returns the B value

Returns true if the option is a Some value.

Returns true if the option is a None value.

Maps the value to a result

Trait Implementations

impl<TM, A: Clone, B: Clone> Clone for EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<TM, A: Copy, B: Copy> Copy for EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

impl<TM, A, B> Default for EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

Returns the "default value" for a type. Read more

impl<TM, A: Debug, B: Debug> Debug for EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

Formats the value using the given formatter.

impl<TM, A: PartialEq, B: PartialEq> PartialEq for EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

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

This method tests for !=.

impl<TM, A: Eq, B: Eq> Eq for EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

impl<TM, A: Hash, B: Hash> Hash for EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

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

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

impl<TM, A> From<Option<A>> for EfficientOption<A, (), TM> where
    A: TaggableValue<TM, One>, 
[src]

Performs the conversion.

impl<TM, A, B> From<Option<(A, B)>> for EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

Performs the conversion.

impl<TM, A, B> Into<Option<(A, B)>> for EfficientOption<A, B, TM> where
    A: TaggableValue<TM, One>, 
[src]

Performs the conversion.

impl<TM, A> Into<Option<A>> for EfficientOption<A, (), TM> where
    A: TaggableValue<TM, One>, 
[src]

Performs the conversion.