NonEmptyItertools

Trait NonEmptyItertools 

Source
pub trait NonEmptyItertools: NonEmptyIterator {
    // Provided methods
    fn cartesian_product<J>(self, other: J) -> Product<Self, J::IntoNEIter>
       where Self: Sized,
             Self::Item: Clone,
             J: IntoNonEmptyIterator,
             <J::IntoNEIter as IntoIterator>::IntoIter: Clone { ... }
    fn all_unique(self) -> bool
       where Self: Sized,
             Self::Item: Eq + Hash { ... }
}
Expand description

A NonEmptyIterator blanket implementation that provides extra adaptors and methods, similar to Itertools for Iterator.

Provided Methods§

Source

fn cartesian_product<J>(self, other: J) -> Product<Self, J::IntoNEIter>

Return a non-empty iterator adaptor that iterates over the non-empty cartesian product of the element sets of two iterators self and J.

NonEmptyIteratorelement type is (Self::Item, J::Item).

use nonempty_collections::*;

let product = nev![0, 1]
    .nonempty_iter()
    .copied()
    .cartesian_product("αβ".chars().try_into_nonempty_iter().unwrap())
    .collect::<NEVec<_>>();
assert_eq!(nev![(0, 'α'), (0, 'β'), (1, 'α'), (1, 'β')], product);
Source

fn all_unique(self) -> bool
where Self: Sized, Self::Item: Eq + Hash,

Check whether all elements are unique (non equal).

§Examples
use nonempty_collections::*;

let data = nev![1, 2, 3, 4, 1, 5];
assert!(!nev![1, 2, 3, 4, 1, 5].nonempty_iter().all_unique());
assert!(nev![2, 3, 4, 1, 5].nonempty_iter().all_unique());

Implementors§