pub trait FilterMapDispatch<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, FA, Marker> {
// Required method
fn dispatch(self, fa: FA) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>;
}Expand description
Trait that routes a filter_map operation to the appropriate type class method.
The Marker type parameter is an implementation detail resolved by
the compiler from the closure’s argument type; callers never specify
it directly. The FA type parameter is inferred from the container
argument: owned for Val dispatch, borrowed for Ref dispatch.
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.B: The type of the result(s) of applying the function.FA: The container type (owned or borrowed), inferred from the argument.Marker: Dispatch marker type, inferred automatically. EitherValorRef.
Required Methods§
Sourcefn dispatch(self, fa: FA) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch(self, fa: FA) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
Perform the dispatched filter_map operation.
§Type Signature
(self, FA) -> Brand B
§Parameters
self: The closure implementing this dispatch.fa: The filterable instance containing the value(s).
§Returns
A new filterable instance containing only the values for which the function returned Some.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = filter_map::<OptionBrand, _, _, _, _>(
|x: i32| if x > 3 { Some(x * 2) } else { None },
Some(5),
);
assert_eq!(result, Some(10));Implementors§
impl<'a, 'b, Brand, A, B, F> FilterMapDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> Option<B> closures to RefFilterable::ref_filter_map.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.B: The type of the result(s) of applying the function.F: The closure type.
impl<'a, Brand, A, B, F> FilterMapDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> Option<B> closures to Filterable::filter_map.
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.B: The type of the result(s) of applying the function.F: The closure type.