BTreeMapWitness

Struct BTreeMapWitness 

Source
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,

Source§

fn fold<A, B, Func>(fa: BTreeMap<K, A>, init: B, f: Func) -> B
where 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: The BTreeMap to 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>
where K: Ord + Clone + 'static,

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 A: Satisfies<NoConstraint>, B: Satisfies<NoConstraint>, 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: The BTreeMap to 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>

Source§

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

The constraint on inner types. Use NoConstraint for fully polymorphic.
Source§

impl<K> HKT2<K> for BTreeMapWitness<K>

Source§

type Type<V> = BTreeMap<K, V>

Specifies that BTreeMapWitness<K> represents the BTreeMap<K, V> type constructor with a fixed key type K.

Auto Trait Implementations§

§

impl<K> Freeze for BTreeMapWitness<K>
where K: Freeze,

§

impl<K> RefUnwindSafe for BTreeMapWitness<K>
where K: RefUnwindSafe,

§

impl<K> Send for BTreeMapWitness<K>
where K: Send,

§

impl<K> Sync for BTreeMapWitness<K>
where K: Sync,

§

impl<K> Unpin for BTreeMapWitness<K>
where K: Unpin,

§

impl<K> UnwindSafe for BTreeMapWitness<K>
where K: UnwindSafe,

Blanket Implementations§

Source§

impl<T, F> AliasFoldable<F> for T
where T: Foldable<F>, F: HKT,

Source§

fn reduce<A, B, Func>(fa: F::Type<A>, init: B, f: Func) -> B
where A: Satisfies<F::Constraint>, Func: FnMut(B, A) -> B,

Alias for fold. Reduces elements to a single value.
Source§

impl<T, F> AliasFunctor<F> for T
where T: Functor<F>, F: HKT,

Source§

fn transform<A, B, Func>(m_a: F::Type<A>, f: Func) -> F::Type<B>
where A: Satisfies<F::Constraint>, B: Satisfies<F::Constraint>, Func: FnMut(A) -> B,

Alias for fmap. Transforms the value inside a container.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Satisfies<NoConstraint> for T