[][src]Struct number_encoding::factoradics::Iter

pub struct Iter<'a, T> { /* fields omitted */ }

Iterates over all permutations of a slice.

The permutations are iterated in value order:

let mut iter = Iter::new(&mut xs);
let mut i = 0;
while let Some(xs) = iter.next() {
    assert_eq!(encode(xs), i);
    i += 1;
}

If the iteration goes to the end (i.e. next returns None), then the slice is restored to its initial value (i.e. increasing):

let saved_xs = xs.clone();
let mut iter = Iter::new(&mut xs);
while iter.next().is_some() {}
assert_eq!(xs, saved_xs);

Examples

let mut iter = Iter::new(&mut xs);
while let Some(xs) = iter.next() {
    process(xs);
}

Methods

impl<'a, T: Ord> Iter<'a, T>[src]

pub fn new(xs: &mut [T]) -> Iter<T>[src]

Constructs an iterator with an increasing slice.

Panics

Panics in debug mode if xs is not increasing.

pub fn next(&mut self) -> Option<&[T]>[src]

Returns the next permutation.

If iteration is over, returns None.

Auto Trait Implementations

impl<'a, T> Send for Iter<'a, T> where
    T: Send

impl<'a, T> Sync for Iter<'a, T> where
    T: Sync

impl<'a, T> Unpin for Iter<'a, T>

impl<'a, T> !UnwindSafe for Iter<'a, T>

impl<'a, T> RefUnwindSafe for Iter<'a, T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]