Struct efficient_enum::EfficientOption
[−]
[src]
pub struct EfficientOption<A, TaggingMethod = TagMSB>(_, _) where A: TaggableValue<TaggingMethod, Two>;
An option type similar to Option<A>
, 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<TaggingMethod, A> EfficientOption<A, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
fn new(a: Option<A>) -> Self
Constructs a new EfficientOption
fn none() -> Self
Constructs an empty EfficientOption
fn some(a: A) -> Self
Constructs an EfficientOption
from an A
value
fn destructure(self) -> Option<A>
Destructures an EfficientOption
fn is_some(&self) -> bool
Returns true
if the option is a Some
value.
fn is_none(&self) -> bool
Returns true
if the option is a None
value.
fn map<R, F: FnOnce(Option<&mut A>) -> R>(&mut self, f: F) -> R
Maps the value to a result
Trait Implementations
impl<TaggingMethod, A: Clone> Clone for EfficientOption<A, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<TaggingMethod, A: Copy> Copy for EfficientOption<A, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
impl<TaggingMethod, A> Default for EfficientOption<A, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
impl<TaggingMethod, A: Debug> Debug for EfficientOption<A, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
impl<TaggingMethod, A: PartialEq> PartialEq for EfficientOption<A, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Self) -> bool
This method tests for !=
.
impl<TaggingMethod, A: Eq> Eq for EfficientOption<A, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
impl<TaggingMethod, A: Hash> Hash for EfficientOption<A, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.