pub fn ref_map_second<'a, Brand: RefBifunctor, A: Clone + 'a, B: 'a, C: 'a>(
g: impl Fn(&B) -> C + 'a,
p: &<Brand as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Brand as Kind_266801a817966495>::Of<'a, A, C>Expand description
Maps a function over the second type argument of the bifunctor by reference.
Free function version that dispatches to the type class’ associated function.
§Type Signature
forall Brand A B C. RefBifunctor Brand => (&B -> C, &Brand A B) -> Brand A C
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the bifunctor.A: The type of the first value (must be Clone).B: The type of the second value.C: The type of the second result.
§Parameters
g: The function to apply to the second value.p: The bifunctor instance (borrowed).
§Returns
A new bifunctor instance with the second value transformed.
§Examples
use fp_library::{
brands::*,
classes::ref_bifunctor::*,
};
let x = Result::<i32, i32>::Ok(5);
let y = ref_map_second::<ResultBrand, _, _, _>(|s: &i32| *s * 2, &x);
assert_eq!(y, Ok(10));