Enum frunk::coproduct::Coproduct
[−]
[src]
pub enum Coproduct<H, T> { Inl(H), Inr(T), }
Enum type representing a Coproduct. Think of this as a Result, but capable of supporting any arbitrary number of types instead of just 2.
To consctruct a Coproduct, you would typically declare a type using the Coprod!
type
macro and then use the inject
method.
Examples
type I32Bool = Coprod!(i32, bool); let co1 = I32Bool::inject(3); let get_from_1a: Option<&i32> = co1.get(); let get_from_1b: Option<&bool> = co1.get(); assert_eq!(get_from_1a, Some(&3)); assert_eq!(get_from_1b, None);Run
Variants
Inl(H)
Coproduct is either H or T, in this case, it is H
Inr(T)
Coproduct is either H or T, in this case, it is T
Trait Implementations
impl<H: PartialEq, T: PartialEq> PartialEq for Coproduct<H, T>
[src]
fn eq(&self, __arg_0: &Coproduct<H, T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Coproduct<H, T>) -> bool
[src]
This method tests for !=
.
impl<H: Debug, T: Debug> Debug for Coproduct<H, T>
[src]
impl<H: Eq, T: Eq> Eq for Coproduct<H, T>
[src]
impl<H: Clone, T: Clone> Clone for Coproduct<H, T>
[src]
fn clone(&self) -> Coproduct<H, T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<H: Copy, T: Copy> Copy for Coproduct<H, T>
[src]
impl<H: PartialOrd, T: PartialOrd> PartialOrd for Coproduct<H, T>
[src]
fn partial_cmp(&self, __arg_0: &Coproduct<H, T>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Coproduct<H, T>) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Coproduct<H, T>) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Coproduct<H, T>) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Coproduct<H, T>) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<H: Ord, T: Ord> Ord for Coproduct<H, T>
[src]
fn cmp(&self, __arg_0: &Coproduct<H, T>) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the minimum of two values. Read more
impl<H: Hash, T: Hash> Hash for Coproduct<H, T>
[src]
fn hash<__HHT: Hasher>(&self, __arg_0: &mut __HHT)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<I, Tail> CoprodInjector<I, Here> for Coproduct<I, Tail>
[src]
impl<Head, I, Tail, TailIndex> CoprodInjector<I, There<TailIndex>> for Coproduct<Head, Tail> where
Tail: CoprodInjector<I, TailIndex>,
[src]
Tail: CoprodInjector<I, TailIndex>,
impl<Head, Tail> CoproductSelector<Head, Here> for Coproduct<Head, Tail>
[src]
impl<Head, FromTail, Tail, TailIndex> CoproductSelector<FromTail, There<TailIndex>> for Coproduct<Head, Tail> where
Tail: CoproductSelector<FromTail, TailIndex>,
[src]
Tail: CoproductSelector<FromTail, TailIndex>,
impl<Head, Tail> CoproductTaker<Head, Here> for Coproduct<Head, Tail>
[src]
impl<Head, FromTail, Tail, TailIndex> CoproductTaker<FromTail, There<TailIndex>> for Coproduct<Head, Tail> where
Tail: CoproductTaker<FromTail, TailIndex>,
[src]
Tail: CoproductTaker<FromTail, TailIndex>,
impl<F, R, FTail, CH, CTail> CoproductFoldable<HCons<F, FTail>, R> for Coproduct<CH, CTail> where
F: FnOnce(CH) -> R,
CTail: CoproductFoldable<FTail, R>,
[src]
F: FnOnce(CH) -> R,
CTail: CoproductFoldable<FTail, R>,
impl<'a, F, R, FTail, CH, CTail> CoproductFoldable<HCons<F, FTail>, R> for &'a Coproduct<CH, CTail> where
F: FnOnce(&'a CH) -> R,
&'a CTail: CoproductFoldable<FTail, R>,
[src]
F: FnOnce(&'a CH) -> R,
&'a CTail: CoproductFoldable<FTail, R>,