Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No example of continuing a specific labeled loop #3821

Open
CoolCat467 opened this issue Jan 21, 2024 · 1 comment
Open

No example of continuing a specific labeled loop #3821

CoolCat467 opened this issue Jan 21, 2024 · 1 comment

Comments

@CoolCat467
Copy link

  • 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.

@chriskrycho chriskrycho added this to the ch3 milestone Mar 29, 2024
@chriskrycho
Copy link
Contributor

Thanks for this and #3820. I think we probably don’t want to add more example code here, but maybe we can sneak in a sentence which says that continue and break work the same way with loop labels as they do without them (worded better than this, of course!). That would minimize the change to the text while still conveying the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants