Rust loops

From wikinotes
Revision as of 14:46, 7 February 2023 by Will (talk | contribs)

General

Breaking/Continuing etc.

break;     // exit loop
continue;  // skip to next iteration of loop

Loop Labels

Loops can be assigned labels, so that you can target which loop to break out of.

'outer_loop: loop {
    loop {
        break 'outer_loop;
    }
}


loop

loop {
    // loop forever
}