pub struct HashMapWitness<K>(/* private fields */);Expand description
Re-exports HashMapWitness, the HKT witness for HashMap<K, V>.
HashMapWitness<K> is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness
for the HashMap<K, V> type constructor, where the key type K is fixed.
It allows HashMap 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<HashMapWitness<K>> for HashMapWitness<K>
impl<K> Foldable<HashMapWitness<K>> for HashMapWitness<K>
Source§fn fold<A, B, Func>(fa: HashMap<K, A>, init: B, f: Func) -> Bwhere
Func: FnMut(B, A) -> B,
fn fold<A, B, Func>(fa: HashMap<K, A>, init: B, f: Func) -> Bwhere
Func: FnMut(B, A) -> B,
Folds (reduces) a HashMap into a single value.
Applies the function f cumulatively to the accumulator and each key-value pair
of the hash map, starting with an initial accumulator value.
§Arguments
fa: TheHashMapto 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<HashMapWitness<K>> for HashMapWitness<K>
impl<K> Functor<HashMapWitness<K>> for HashMapWitness<K>
Source§fn fmap<A, B, Func>(
m_a: <HashMapWitness<K> as HKT2<K>>::Type<A>,
f: Func,
) -> <HashMapWitness<K> as HKT2<K>>::Type<B>where
Func: FnMut(A) -> B,
fn fmap<A, B, Func>(
m_a: <HashMapWitness<K> as HKT2<K>>::Type<A>,
f: Func,
) -> <HashMapWitness<K> as HKT2<K>>::Type<B>where
Func: FnMut(A) -> B,
Implements the fmap operation for HashMap<K, V>.
Applies the function f to each value in the hash map, producing a new hash map
with the same keys but transformed values.
§Arguments
m_a: TheHashMapto map over.f: The function to apply to each value.
§Returns
A new HashMap with the function applied to each of its values.