Trait IterBasic

Source
pub trait IterBasic: IntoIterator + Sized {
    // Provided methods
    fn vfold<U, F>(self, init: U, f: F) -> U
       where F: FnMut(U, Self::Item) -> U,
             Self::Item: IsNone { ... }
    fn vfold2<U, I2, F>(self, other: I2, init: U, f: F) -> U
       where I2: IntoIterator,
             I2::Item: IsNone,
             F: FnMut(U, Self::Item, I2::Item) -> U,
             Self::Item: IsNone { ... }
    fn vfold_n<U, F>(self, init: U, f: F) -> (usize, U)
       where F: FnMut(U, <Self::Item as IsNone>::Inner) -> U,
             Self::Item: IsNone { ... }
    fn vapply<F>(self, f: F)
       where F: FnMut(<Self::Item as IsNone>::Inner),
             Self::Item: IsNone { ... }
    fn vapply_n<F>(self, f: F) -> usize
       where F: FnMut(<Self::Item as IsNone>::Inner),
             Self::Item: IsNone { ... }
}
Expand description

A trait providing additional iterator methods for types that can be converted into an iterator.

Provided Methods§

Source

fn vfold<U, F>(self, init: U, f: F) -> U
where F: FnMut(U, Self::Item) -> U, Self::Item: IsNone,

Folds the elements of the iterator, skipping None values.

§Arguments
  • init - The initial value for the fold operation.
  • f - A closure that takes the accumulator and a non-None item, returning a new accumulator.
§Returns

The final accumulated value.

Source

fn vfold2<U, I2, F>(self, other: I2, init: U, f: F) -> U
where I2: IntoIterator, I2::Item: IsNone, F: FnMut(U, Self::Item, I2::Item) -> U, Self::Item: IsNone,

Folds two iterators together, skipping None values from either iterator.

§Arguments
  • other - The second iterator to fold with.
  • init - The initial value for the fold operation.
  • f - A closure that takes the accumulator and non-None items from both iterators, returning a new accumulator.
§Returns

The final accumulated value.

Source

fn vfold_n<U, F>(self, init: U, f: F) -> (usize, U)
where F: FnMut(U, <Self::Item as IsNone>::Inner) -> U, Self::Item: IsNone,

Folds the elements of the iterator, skipping None values and counting non-None elements.

§Arguments
  • init - The initial value for the fold operation.
  • f - A closure that takes the accumulator and the inner value of a non-None item, returning a new accumulator.
§Returns

A tuple containing the count of non-None elements and the final accumulated value.

Source

fn vapply<F>(self, f: F)
where F: FnMut(<Self::Item as IsNone>::Inner), Self::Item: IsNone,

Applies a function to each non-None element of the iterator.

§Arguments
  • f - A closure that takes the inner value of a non-None item and performs some operation.
Source

fn vapply_n<F>(self, f: F) -> usize
where F: FnMut(<Self::Item as IsNone>::Inner), Self::Item: IsNone,

Applies a function to each non-None element of the iterator and counts the number of applications.

§Arguments
  • f - A closure that takes the inner value of a non-None item and performs some operation.
§Returns

The number of non-None elements processed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§