Macro tear::next[][src]

macro_rules! next {
    () => { ... };
    ( $id:expr ) => { ... };
}

Dirty shortcut for creating a Looping::Continue

Description

If called with no arguments, it skips the current loop.

If called with the label index, it skips the corresponding loop (see twist!).

Used for writing short twist! statements that continue an enclosing loop. See examples.

Note that this macro will fail to compile if twist! can break with a value or when using twist -label.

Examples

use tear::{twist, next};

let mut i = 0;
loop {
    i += 1;
    
    if i < 5 {
        twist! { next!() }
    }
    break;
}

let mut i = 0;
'a: loop {
    i += 1;
    loop {
        if i < 8 {
            twist! { -label 'a | next!(0) }
        }
        break 'a;
    }
}

Naming

It is named after the equivalent of continue in Perl. continue is a keyword so we can’t name the macro continue! unless we use r#continue!.

See also