pub struct Iter<'a, T> { /* private fields */ }
Expand description
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);
}
Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Iter<'a, T>
impl<'a, T> RefUnwindSafe for Iter<'a, T>where
T: RefUnwindSafe,
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>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more