VecDequeWitness

Struct VecDequeWitness 

Source
pub struct VecDequeWitness;
Expand description

Re-exports VecDequeWitness, the HKT witness for VecDeque<T>. VecDequeWitness is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for the VecDeque<T> type constructor. It allows VecDeque to be used with generic functional programming traits like Functor and Foldable.

By implementing HKT for VecDequeWitness, we can write generic functions that operate on any type that has the “shape” of VecDeque, without knowing the inner type T.

Trait Implementations§

Source§

impl Foldable<VecDequeWitness> for VecDequeWitness

Source§

fn fold<A, B, Func>(fa: VecDeque<A>, init: B, f: Func) -> B
where Func: FnMut(B, A) -> B,

Folds (reduces) a VecDeque into a single value.

Applies the function f cumulatively to the elements of the vector deque, starting with an initial accumulator value.

§Arguments
  • fa: The VecDeque to fold.
  • init: The initial accumulator value.
  • f: The folding function.
§Returns

The accumulated result.

Source§

impl Functor<VecDequeWitness> for VecDequeWitness

Source§

fn fmap<A, B, Func>( m_a: <VecDequeWitness as HKT>::Type<A>, f: Func, ) -> <VecDequeWitness as HKT>::Type<B>
where Func: FnMut(A) -> B,

Implements the fmap operation for VecDeque<T>.

Applies the function f to each element in the vector deque, producing a new vector deque.

§Arguments
  • m_a: The VecDeque to map over.
  • f: The function to apply to each element.
§Returns

A new VecDeque with the function applied to each of its elements.

Source§

impl HKT for VecDequeWitness

Source§

type Type<T> = VecDeque<T>

Specifies that VecDequeWitness represents the VecDeque<T> type constructor.

Auto Trait Implementations§

Blanket Implementations§

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.