Skip to main content

Module ref_foldable

Module ref_foldable 

Source
Expand description

By-reference variant of Foldable.

User story: “I want to fold over a memoized value without consuming it.”

This trait is for types like Lazy where the container holds a cached value accessible by reference. The closures receive &A instead of A, avoiding unnecessary cloning.

§Examples

use fp_library::{
	brands::*,
	functions::explicit::*,
	types::*,
};

let lazy = RcLazy::new(|| 10);
let result =
	fold_map::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _, _, _>(|a: &i32| a.to_string(), &lazy);
assert_eq!(result, "10");

Traits§

RefFoldable
By-reference folding over a structure.