pub struct BTreeMapWitness<K>(/* private fields */);Expand description
BTreeMapWitness<K> is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness
for the BTreeMap<K, V> type constructor, where the key type K is fixed.
It allows BTreeMap to be used with generic functional programming traits like Functor
and Foldable by fixing one of its type parameters.
Trait Implementations§
Source§impl<K> Foldable<BTreeMapWitness<K>> for BTreeMapWitness<K>where
K: Ord + 'static,
impl<K> Foldable<BTreeMapWitness<K>> for BTreeMapWitness<K>where
K: Ord + 'static,
Source§fn fold<A, B, Func>(fa: BTreeMap<K, A>, init: B, f: Func) -> Bwhere
Func: FnMut(B, A) -> B,
fn fold<A, B, Func>(fa: BTreeMap<K, A>, init: B, f: Func) -> Bwhere
Func: FnMut(B, A) -> B,
Folds (reduces) a BTreeMap into a single value.
Applies the function f cumulatively to the accumulator and each key-value pair
of the B-tree map, starting with an initial accumulator value.
§Arguments
fa: TheBTreeMapto fold.init: The initial accumulator value.f: The folding function, which takes the accumulator and a key-value pair.
§Returns
The final accumulated value after processing all elements.
Source§impl<K> Functor<BTreeMapWitness<K>> for BTreeMapWitness<K>
impl<K> Functor<BTreeMapWitness<K>> for BTreeMapWitness<K>
Source§fn fmap<A, B, Func>(
m_a: <BTreeMapWitness<K> as HKT2<K>>::Type<A>,
f: Func,
) -> <BTreeMapWitness<K> as HKT2<K>>::Type<B>where
Func: FnMut(A) -> B,
fn fmap<A, B, Func>(
m_a: <BTreeMapWitness<K> as HKT2<K>>::Type<A>,
f: Func,
) -> <BTreeMapWitness<K> as HKT2<K>>::Type<B>where
Func: FnMut(A) -> B,
Implements the fmap operation for BTreeMap<K, V>.
Applies the function f to each value in the B-tree map, producing a new B-tree map
with the same keys but transformed values.
§Arguments
m_a: TheBTreeMapto map over.f: The function to apply to each value.
§Returns
A new BTreeMap with the function applied to each of its values.