continue_if

Macro continue_if 

Source
macro_rules! continue_if {
    ($predicate:expr $(,)?) => { ... };
    ($predicate:expr, $label:tt $(,)?) => { ... };
}
Expand description

continue to the next iteration of a loop if a given predicate evaluates to true.

Supports optionally providing a loop label to specify the loop in which to continue.

§Usage

continue_if!(predicate)

continue_if!(predicate, label)

§Examples

§Predicate only
use flow_control::continue_if;

let mut v = Vec::new();
for outer_n in 1..3 {
    for inner_n in 1..5 {
        continue_if!(inner_n == 3);
        v.push((outer_n, inner_n));
    }
}

assert_eq!(
    v,
    vec![
        (1, 1), (1, 2), (1, 4),
        (2, 1), (2, 2), (2, 4),
    ]
);
§Predicate and label
use flow_control::continue_if;

let mut v = Vec::new();
'outer: for outer_n in 1..3 {
    for inner_n in 1..5 {
        continue_if!(inner_n == 3, 'outer);
        v.push((outer_n, inner_n));
    }
}

assert_eq!(
    v,
    vec![
        (1, 1), (1, 2),
        (2, 1), (2, 2),
    ]
);