Skip to main content

Decide

Trait Decide 

Source
pub trait Decide: Contravariant {
    // Required method
    fn choose<A, B, C>(
        f: impl Fn(C) -> Result<A, B> + 'static,
        fa: Self::Of<A>,
        fb: Self::Of<B>,
    ) -> Self::Of<C>
       where A: 'static,
             B: 'static,
             C: 'static;
}
Expand description

Decide: the contravariant analogue of Alt.

Given a way to split C into either A or B, and contravariant functors over A and B, produce a contravariant functor over C.

Laws:

  • Associativity: choose(f, choose(g, a, b), c) == choose(h, a, choose(i, b, c)) (where f/g/h/i are appropriate splitting functions)

Required Methods§

Source

fn choose<A, B, C>( f: impl Fn(C) -> Result<A, B> + 'static, fa: Self::Of<A>, fb: Self::Of<B>, ) -> Self::Of<C>
where A: 'static, B: 'static, C: 'static,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§