Expand description
Dispatch for Bitraversable::bi_traverse and
RefBitraversable::ref_bi_traverse.
Provides the BiTraverseDispatch trait and a unified
explicit::bi_traverse free function that routes to the appropriate trait
method based on the closures’ argument types.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
// Owned: dispatches to Bitraversable::bi_traverse
let x: Result<i32, i32> = Ok(5);
let y = bi_traverse::<RcFnBrand, ResultBrand, _, _, _, _, OptionBrand, _, _>(
(|e: i32| Some(e + 1), |s: i32| Some(s * 2)),
x,
);
assert_eq!(y, Some(Ok(10)));
// By-ref: dispatches to RefBitraversable::ref_bi_traverse
let x: Result<i32, i32> = Ok(5);
let y = bi_traverse::<RcFnBrand, ResultBrand, _, _, _, _, OptionBrand, _, _>(
(|e: &i32| Some(e + 1), |s: &i32| Some(s * 2)),
&x,
);
assert_eq!(y, Some(Ok(10)));Modules§
- explicit
- Explicit dispatch functions requiring a Brand turbofish.
Traits§
- BiTraverse
Dispatch - Trait that routes a bi_traverse operation to the appropriate type class method.
Functions§
- bi_
traverse - Traverses a bifoldable structure with an applicative effect, inferring the brand from the container type.