-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Document the question mark operator in reference and the book's syntax index #37664
Conversation
r? @Manishearth (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -2890,6 +2890,10 @@ before the expression they apply to. | |||
If the `&` or `&mut` operators are applied to an rvalue, a | |||
temporary value is created; the lifetime of this temporary value | |||
is defined by [syntactic rules](#temporary-lifetimes). | |||
* `?` | |||
: Propagating errors if applied to `Err(_)` and unwrapping if | |||
applied to Ok(_). Only works on the `Result<T,E>` type, |
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: space after comma in result
@@ -94,6 +94,7 @@ | |||
* `|=` (`var |= expr`): bitwise or & assignment. Overloadable (`BitOrAssign`). | |||
* `||` (`expr || expr`): logical or. | |||
* `_`: "ignored" pattern binding (see [Patterns (Ignoring bindings)]). Also used to make integer-literals readable (see [Reference (Integer literals)]). | |||
* `?` (`expr?`): propagation when `Err(_)` is encountered, unwrapping otherwise. Similar to the [`try!` macro]. |
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.
error propagation
r=me with nits |
@bors r+ rollup thanks! |
📌 Commit cf20943 has been approved by |
Sorry, I've forgotten two backticks. @Manishearth can you re-review? |
Dear @Manishearth, |
Yes, I think it works with carrier, but it's unstable. deferring to nrc who pushed for the carrier stuff iirc r? @nrc |
Is |
I think it already was? |
This correct |
@bors: r+ rollup (The Carrier trait exists, but only for purposes of future compatibility, I don't think it should be advertised/documented) |
📌 Commit 1e9aad7 has been approved by |
Document the question mark operator in reference and the book's syntax index The question mark operator will be stabilized for the Rust 1.13 release (unfortunately). Even though I don't like the operator, it still should be documented in the syntax index in the book and in the reference. Maybe there are people who also want to change the book's chapters on error handling, depending on their views of what idiomatic error handling is, now that the operator is stable, but I don't want to and I'd prefer to keep this PR focused on the reference and syntax index only. Please also apply this PR to the beta branch of rust.
Reasonable backport. |
The question mark operator will be stabilized for the Rust 1.13 release (unfortunately). Even though I don't like the operator, it still should be documented in the syntax index in the book and in the reference.
Maybe there are people who also want to change the book's chapters on error handling, depending on their views of what idiomatic error handling is, now that the operator is stable, but I don't want to and I'd prefer to keep this PR focused on the reference and syntax index only.
Please also apply this PR to the beta branch of rust.