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.
§Constraint
BTreeMapWitness uses NoConstraint, meaning it works with any value type V.
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>
fn fmap<A, B, Func>( m_a: <BTreeMapWitness<K> as HKT2<K>>::Type<A>, f: Func, ) -> <BTreeMapWitness<K> as HKT2<K>>::Type<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.
Source§impl<K> HKT for BTreeMapWitness<K>
impl<K> HKT for BTreeMapWitness<K>
Source§type Type<V> = BTreeMap<K, V>
type Type<V> = BTreeMap<K, V>
Specifies that BTreeMapWitness<K> also acts as a single-parameter HKT,
where the K parameter is considered part of the “witness” itself.
Source§type Constraint = NoConstraint
type Constraint = NoConstraint
NoConstraint for fully polymorphic.