book
book copied to clipboard
Ch03-05 Control flow: Explicitly document if it's valid to break from a loop with return keyword
- [x] I have checked the latest
mainbranch to see if this has already been fixed - [x] 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
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.