pub enum LoopControl<B = (), C = (), S = ()> {
Break(B),
Continue(C),
Repeat(S),
}
Expand description
Used to emulate the keywords’ behavior inside the closure passed to ForEachRepeat::for_each_repeat
.
§Example
use for_each_repeat::{ForEachRepeat, LoopControl};
let r = (2..100).for_each_repeat(|x| {
if 323 % x == 0 {
return LoopControl::Break(x)
}
LoopControl::Continue(())
});
assert_eq!(r, Some(17));
It is named LoopControl
to avoid confusion with ControlFlow
enum from std
.
Variants§
Break(B)
Break out of the loop and optionally return a resulting value.
Continue(C)
Skip the rest of the loop and continue the next iteration advancing the iterator.
Repeat(S)
Come back to the beginning of the loop not advancing the iterator, with the given value for the iteration.
Implementations§
Source§impl<C, S> LoopControl<(), C, S>
impl<C, S> LoopControl<(), C, S>
Source§impl<B, S> LoopControl<B, (), S>
impl<B, S> LoopControl<B, (), S>
Trait Implementations§
Source§impl<B: Clone, C: Clone, S: Clone> Clone for LoopControl<B, C, S>
impl<B: Clone, C: Clone, S: Clone> Clone for LoopControl<B, C, S>
Source§fn clone(&self) -> LoopControl<B, C, S>
fn clone(&self) -> LoopControl<B, C, S>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<B, C, S> Display for LoopControl<B, C, S>
impl<B, C, S> Display for LoopControl<B, C, S>
Source§impl<B: Ord, C: Ord, S: Ord> Ord for LoopControl<B, C, S>
impl<B: Ord, C: Ord, S: Ord> Ord for LoopControl<B, C, S>
Source§fn cmp(&self, other: &LoopControl<B, C, S>) -> Ordering
fn cmp(&self, other: &LoopControl<B, C, S>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<B: PartialOrd, C: PartialOrd, S: PartialOrd> PartialOrd for LoopControl<B, C, S>
impl<B: PartialOrd, C: PartialOrd, S: PartialOrd> PartialOrd for LoopControl<B, C, S>
impl<B: Copy, C: Copy, S: Copy> Copy for LoopControl<B, C, S>
impl<B: Eq, C: Eq, S: Eq> Eq for LoopControl<B, C, S>
impl<B, C, S> StructuralPartialEq for LoopControl<B, C, S>
Auto Trait Implementations§
impl<B, C, S> Freeze for LoopControl<B, C, S>
impl<B, C, S> RefUnwindSafe for LoopControl<B, C, S>
impl<B, C, S> Send for LoopControl<B, C, S>
impl<B, C, S> Sync for LoopControl<B, C, S>
impl<B, C, S> Unpin for LoopControl<B, C, S>
impl<B, C, S> UnwindSafe for LoopControl<B, C, S>
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