pub fn filter_map<'a, FA, A: 'a, B: 'a, Marker>(
f: impl FilterMapDispatch<'a, <FA as InferableBrand_cdc7cd43dac7585f>::Brand, A, B, FA, Marker>,
fa: FA,
) -> <<FA as InferableBrand_cdc7cd43dac7585f>::Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>where
FA: InferableBrand_cdc7cd43dac7585f,Expand description
Filters and maps the values in a filterable context, inferring the brand from the container type.
The Brand type parameter is inferred from the concrete type of fa
via InferableBrand. Both owned and borrowed containers are supported.
For types with multiple brands, use
explicit::filter_map with a turbofish.
§Type Signature
forall Brand A B. Filterable Brand => (A -> Option B, Brand A) -> Brand B
§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.B: The type of the result(s) of applying the function.Marker: Dispatch marker type, inferred automatically.
§Parameters
f: The function to apply to each value. ReturnsSome(b)to keep orNoneto discard.fa: The filterable instance (owned or borrowed).
§Returns
A new filterable instance containing only the kept values.
§Examples
use fp_library::functions::*;
let y = filter_map(|x: i32| if x > 3 { Some(x) } else { None }, Some(5));
assert_eq!(y, Some(5));