rust-lang / book

The Rust Programming Language

Home Page:https://doc.rust-lang.org/book/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No example of continuing a specific labeled loop

CoolCat467 opened this issue · comments

  • I have searched open and closed issues and pull requests for duplicates, using these search terms:
    • "labeled loop continue"
    • "continuing labeled loop"
    • "continuing loop with label"
  • I have checked the latest main branch to see if this has already been fixed, in this file:
    • src/ch03-05-control-flow.md

URL to the section(s) of the book with this problem:
https://github.com/rust-lang/book/blob/main/src/ch03-05-control-flow.md
https://doc.rust-lang.org/book/ch03-05-control-flow.html

Description of the problem:
There are no examples on continuing a higher up labeled loop when there are nested loops.
Ex

'one: loop {
    'two: loop {
        continue; // How to continue `'one` instead of `'two`?
    }
}

Suggested fix:
Adding section on how continue can take an optional label and continue the loop with that label instead of just the current loop scope.