Skip to main content

Module ref_functor

Module ref_functor 

Source
Expand description

A type class for types that can be mapped over, returning references.

§Examples

use fp_library::{
    brands::*,
    classes::*,
    types::*,
    functions::map_ref,
};

let memo = Lazy::<_, RcLazyConfig>::new(|| 10);
let mapped = map_ref::<LazyBrand<RcLazyConfig>, _, _, _>(
    |x: &i32| *x * 2,
    memo
);
assert_eq!(*mapped.get(), 20);

Traits§

RefFunctor
A type class for types that can be mapped over, returning references.

Functions§

map_ref
Maps a function over the values in the functor context, where the function takes a reference.