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

Ch03-05 Control flow: Explicitly document if it's valid to break from a loop with return keyword #3114

Closed
2 tasks done
Henkhogan opened this issue Apr 11, 2022 · 1 comment · Fixed by #3889
Closed
2 tasks done

Comments

@Henkhogan
Copy link

Henkhogan commented Apr 11, 2022

  • I have checked the latest main branch to see if this has already been fixed
  • I have searched existing issues and pull requests for duplicates

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

Description of the problem: the chapter does not tell if

return value;

is equivalent to

break value;

Suggested fix:
Since I read the documentation without ever compiling a rust project, I can not tell if they are equivalent or not

@carols10cents
Copy link
Member

Hi, thank you! I will clear this up in the text when I'm next working on Chapter 3.

To answer your immediate question, return always goes out of the current function while break only exits the current loop.

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

Successfully merging a pull request may close this issue.

3 participants