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 for returning a value from labeled loops #3820

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

No example for returning a value from labeled loops #3820

CoolCat467 opened this issue Jan 21, 2024 · 1 comment

Comments

@CoolCat467
Copy link

CoolCat467 commented Jan 21, 2024

  • I have searched open and closed issues and pull requests for duplicates, using these search terms:
    • "Return a value from labeled loops"
  • 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 is nothing mentioned about how you return (loop break) a value from a loop you are breaking that has a label.

Suggested fix:
Add example on how you return (loop break) a value from a labeled loop, as the page describes both loop break returning a value and breaking from a loop with a label, and it's not immediately obvious how you both break from a labeled loop and return a value from the loop scope at the same time.

People on StackOverflow asking about this same issue:
https://stackoverflow.com/questions/72927882/return-a-value-from-labeled-loops

@chriskrycho
Copy link
Contributor

For reference for myself and @carols10cents, see my comment over on #3821: I think we can write a single sentence that addresses this, probably.

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