-
Notifications
You must be signed in to change notification settings - Fork 2
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
Faq tweaks: batch 1 #2
Conversation
If you're looking for a way to avoid handling [`Result`s][Result] in other people's code, there's always [`unwrap()`][unwrap], but it's probably not what you want. [`Result`][Result] is an indicator that some computation may or may not complete successfully. Requiring you to handle these failures explicitly is one of the ways that Rust encourages robustness. If you really don't want to handle an error, use [`unwrap()`][unwrap], but know that doing so means that the given code will cause the entire process to panic on failure, which is usually undesirable. | ||
If you're looking for a way to avoid handling [`Result`s][Result] in other people's code, there's always [`unwrap()`][unwrap], but it's probably not what you want. [`Result`][Result] is an indicator that some computation may or may not complete successfully. Requiring you to handle these failures explicitly is one of the ways that Rust encourages robustness. Rust provides tools like the [`try!` macro][TryMacro] to make handling failures ergonomic. | ||
|
||
If you really don't want to handle an error, use [`unwrap()`][unwrap], but know that doing so means that the given code will cause the entire process to panic on failure, which is usually undesirable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "entire thread" is more accurate
@glaebhoerl Thanks! Pushed a new commit to address your comments. |
@@ -155,7 +162,7 @@ fn is_odd(x: i64) -> bool { | |||
} | |||
``` | |||
|
|||
In each example, the last line of the function is the return value of that function. It is important to note that if a function ends in a semicolon, its return type will be `()`, indicating no returned value. Implicit returns must omit the semicolon to work. | |||
In each example, the last line of the function is the return value of that function. It is important to note that if a block ends in a semicolon, its return type will be `()`, indicating no returned value. Implicit returns must omit the semicolon to work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you changed 'function' to 'block' while the rest of the sentence talks about 'return' types. I don't typically think of blocks as 'returning' something and haven't seen 'return' used this way. The preceding sentence is also talking about functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, good point. To be honest I've never found the concept of "implicit return" to be a helpful way to think about what's going on here. Anyway, I'll back out this particular change.
Thanks. These are good improvements. |
Tweaks to the community and user groups page
Here's my first batch of edits to the FAQ, covering up through "Design Patterns".
I plan to get through the rest and open a second PR later today.
r? @brson @AndrewBrinker