pub fn filter<'a, FA, A: 'a + Clone, Brand>(
f: impl FilterDispatch<'a, Brand, A, FA, <FA as InferableBrand_cdc7cd43dac7585f<'a, Brand, A>>::Marker>,
fa: FA,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>where
Brand: Kind_cdc7cd43dac7585f,
FA: InferableBrand_cdc7cd43dac7585f<'a, Brand, A>,Expand description
Filters the values in a filterable context using a predicate, inferring the brand from the container type.
The Brand type parameter is inferred from the concrete type of fa
via the InferableBrand trait. Both owned and borrowed containers are supported.
For types with multiple brands, use
explicit::filter with a turbofish.
§Type Signature
forall Brand A. Filterable Brand => (A -> bool, Brand A) -> Brand A
§Type Parameters
'a: The lifetime of the values.FA: The container type (owned or borrowed). Brand is inferred from this.A: The type of the value(s) inside the filterable.Brand: The brand, inferred via InferableBrand from FA and the element type.
§Parameters
f: The predicate to apply to each value.fa: The filterable instance (owned or borrowed).
§Returns
A new filterable instance containing only the values satisfying the predicate.
§Examples
use fp_library::functions::*;
let y = filter(|x: i32| x > 3, Some(5));
assert_eq!(y, Some(5));