pub trait FunctorFilter: Functor {
// Required method
fn filter_map<A, B>(
fa: Self::Of<A>,
f: impl Fn(A) -> Option<B>,
) -> Self::Of<B>;
// Provided method
fn filter<A>(fa: Self::Of<A>, pred: impl Fn(&A) -> bool) -> Self::Of<A>
where A: Clone { ... }
}Expand description
FunctorFilter: a Functor that can filter elements during mapping.
Laws:
- Identity:
filter_map(fa, Some) == fa - Composition:
filter_map(filter_map(fa, f), g) == filter_map(fa, |a| f(a).and_then(g))
Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl FunctorFilter for OptionF
impl FunctorFilter for VecF
Available on crate features
alloc or std only.