Trait frunk::coproduct::CoproductTaker [] [src]

pub trait CoproductTaker<S, I> {
    fn take(self) -> Option<S>;
}

Trait for retrieving a coproduct element by type.

Returns an Option (notice that the inside of the option is a value)

Example

type I32Bool = Coprod!(i32, f32);

let co1 = I32Bool::inject(42f32);

let get_from_1a: Option<i32> = co1.take();
let get_from_1b: Option<f32> = co1.take();
assert_eq!(get_from_1a, None);
assert_eq!(get_from_1b, Some(42f32));Run

Required Methods

Implementors