pub trait MapWithIndexDispatch<'a, Brand: Kind_cdc7cd43dac7585f + WithIndex, 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 map_with_index 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 functor.A: The type of the value(s) inside the functor.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 map_with_index operation.
§Type Signature
(self, FA) -> Brand B
§Parameters
self: The closure implementing this dispatch.fa: The functor instance containing the value(s).
§Returns
A new functor instance containing the result(s) of applying the function with index.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = map_with_index::<VecBrand, _, _, _, _>(|i, x: i32| x + i as i32, vec![10, 20, 30]);
assert_eq!(result, vec![10, 21, 32]);Implementors§
impl<'a, 'b, Brand, A, B, F> MapWithIndexDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Fwhere
Brand: RefFunctorWithIndex,
A: 'a,
B: 'a,
Brand::Index: 'a,
F: Fn(Brand::Index, &A) -> B + 'a,
Routes Fn(Brand::Index, &A) -> B closures to RefFunctorWithIndex::ref_map_with_index.
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 functor.A: The type of the value(s) inside the functor.B: The type of the result(s) of applying the function.F: The closure type.
impl<'a, Brand, A, B, F> MapWithIndexDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A) -> B closures to FunctorWithIndex::map_with_index.
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the functor.A: The type of the value(s) inside the functor.B: The type of the result(s) of applying the function.F: The closure type.