Struct efficient_enum::EfficientOptionTuple
[−]
[src]
pub struct EfficientOptionTuple<A, B, TaggingMethod = TagMSB>(_, _, _) where A: TaggableValue<TaggingMethod, Two>;
An option type similar to (A, Option<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 &EfficientOptionTuple
. The reason
for this is that doing so would expose the private tag info.
Methods
impl<TaggingMethod, A, B> EfficientOptionTuple<A, B, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
fn new(a: A, b: Option<B>) -> Self
Constructs a new EfficientOptionTuple
fn none(a: A) -> Self
Constructs an EfficientOptionTuple
with no B
value
fn some(a: A, b: B) -> Self
Constructs an EfficientOptionTuple
with a B
value
fn destructure(self) -> (A, Option<B>)
Destructures an EfficientOptionTuple
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 clone_0(self) -> A where A: Clone
Clones the A
value
fn clone_1(self) -> Option<B> where B: Clone
Clones the B
value if one exists
fn ref_1(&self) -> Option<&B>
Gets a reference to the B
value if one exists
fn mut_1(&mut self) -> Option<&mut B>
Gets mutable a reference to the B
value if one exists
fn replace_0(&mut self, a: A) -> A
Replaces the A
value
fn replace_1(&mut self, b: Option<B>) -> Option<B>
Replaces the B
value
fn map<R, F: FnOnce(&mut A, Option<&mut B>) -> R>(&mut self, f: F) -> R
Maps the A
and B
values to a result
Trait Implementations
impl<TaggingMethod, A: Clone, B: Clone> Clone for EfficientOptionTuple<A, B, 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)
Performs copy-assignment from source
. Read more
impl<TaggingMethod, A: Copy, B: Copy> Copy for EfficientOptionTuple<A, B, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
impl<TaggingMethod, A: Default, B> Default for EfficientOptionTuple<A, B, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
impl<TaggingMethod, A: Debug, B: Debug> Debug for EfficientOptionTuple<A, B, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
impl<TaggingMethod, A: PartialEq, B: PartialEq> PartialEq for EfficientOptionTuple<A, B, 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, B: Eq> Eq for EfficientOptionTuple<A, B, TaggingMethod> where A: TaggableValue<TaggingMethod, Two>
[src]
impl<TaggingMethod, A: Hash, B: Hash> Hash for EfficientOptionTuple<A, B, 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.