[−][src]Struct number_encoding::factoradics::Iter
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,
T: Send,
impl<'a, T> Sync for Iter<'a, T> where
T: Sync,
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,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,