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

Coproduct is either H or T, in this case, it is H

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]

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

This method tests for !=.

impl<H: Debug, T: Debug> Debug for Coproduct<H, T>
[src]

Formats the value using the given formatter.

impl<H: Eq, T: Eq> Eq for Coproduct<H, T>
[src]

impl<H: Clone, T: Clone> Clone for Coproduct<H, T>
[src]

Returns a copy of the value. Read more

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]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

This method returns an Ordering between self and other. 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]

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]

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]

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]

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]

impl<CH, CTail> AsRef<Coproduct<CH, CTail>> for Coproduct<CH, CTail>
[src]

Performs the conversion.