Itertools

Trait Itertools 

Source
pub trait Itertools: Iterator {
    // Provided methods
    fn looping_forever(self) -> LoopingForever<Self::Item> 
       where Self: Sized + Iterator,
             Self::Item: Clone { ... }
    fn collect_exact(self, count: usize) -> Vec<Option<Self::Item>>
       where Self: Sized + Iterator,
             Self::Item: Clone { ... }
    fn collect_exact_or(self, count: usize, def: Self::Item) -> Vec<Self::Item>
       where Self: Sized + Iterator,
             Self::Item: Clone { ... }
    fn collect_exact_or_default(self, count: usize) -> Vec<Self::Item>
       where Self: Sized + Iterator,
             Self::Item: Clone + Default { ... }
    fn collect_next_chunk(&mut self, count: usize) -> Vec<Self::Item> { ... }
    fn joining(self, delim: Self::Item) -> Joining<Self, Self::Item>
       where Self: Sized,
             Self::Item: Clone { ... }
    fn joining_multi(
        self,
        delim: &[Self::Item],
    ) -> MultiJoining<Self, Self::Item>
       where Self: Sized,
             Self::Item: Clone { ... }
}
Expand description

Itertools adds helpful additional methods to Iterator

Provided Methods§

Source

fn looping_forever(self) -> LoopingForever<Self::Item>
where Self: Sized + Iterator, Self::Item: Clone,

Returns an iterator that never ends, sequentially looping over all items in this iterator forever, unless there are no items in the iterator.

Source

fn collect_exact(self, count: usize) -> Vec<Option<Self::Item>>
where Self: Sized + Iterator, Self::Item: Clone,

Collects a specific amount of items from the iterator. The underlying iterator may return more, or less items than the specified count. Any remaining uncollected items will be discarded. If count is greater than the length of the underlying iterator, then the remainder of the returned vector will be None.

Source

fn collect_exact_or(self, count: usize, def: Self::Item) -> Vec<Self::Item>
where Self: Sized + Iterator, Self::Item: Clone,

Same behavior as Itertools::collect_exact, except rather than returning ‘None’ after the end, it returns the specified value

Source

fn collect_exact_or_default(self, count: usize) -> Vec<Self::Item>
where Self: Sized + Iterator, Self::Item: Clone + Default,

Same behavior as Itertools::collect_exact, except rather than returning ‘None’ after the end, it returns the default value

Source

fn collect_next_chunk(&mut self, count: usize) -> Vec<Self::Item>

Collects and returns upto ‘count’ items from this iterator. If this iterator is exhausted, the returned vector is empty. Note, the returned vector may have up to the requested number of items if the iterator exhausts before filling the chunk.

Source

fn joining(self, delim: Self::Item) -> Joining<Self, Self::Item>
where Self: Sized, Self::Item: Clone,

Returns the elements in this iterator interspersed with the joining delimiter. For example, if this iterator contains [A, B, C, D] and the delimiter is z, then the final iteration sequence will be [A, z, B, z, C, z, D]

Source

fn joining_multi(self, delim: &[Self::Item]) -> MultiJoining<Self, Self::Item>
where Self: Sized, Self::Item: Clone,

Returns the elements in this iterator interspersed with the elements in the joining delimeter. For example, if this iterator contains [A, B, C, D] and the delimiters are [1, 2], then the final iteration sequence will be [A, 1, 2, B, 1, 2, C, 1, 2, D]

Implementors§

Source§

impl<T> Itertools for T
where T: Iterator + ?Sized,