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

Document the question mark operator in reference and the book's syntax index #37664

Merged
merged 1 commit into from
Nov 10, 2016

Conversation

est31
Copy link
Member

@est31 est31 commented Nov 9, 2016

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.

@rust-highfive
Copy link
Collaborator

r? @Manishearth

(rust_highfive has picked a reviewer for you, use r? to override)

@est31 est31 changed the title Document the question mark operator Document the question mark operator in reference and the book's syntax index Nov 9, 2016
@@ -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,
Copy link
Member

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].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error propagation

@Manishearth
Copy link
Member

r=me with nits

@Manishearth
Copy link
Member

@bors r+ rollup

thanks!

@bors
Copy link
Contributor

bors commented Nov 9, 2016

📌 Commit cf20943 has been approved by Manishearth

@est31
Copy link
Member Author

est31 commented Nov 9, 2016

Sorry, I've forgotten two backticks. @Manishearth can you re-review?

@KalitaAlexey
Copy link
Contributor

Dear @Manishearth,
Have ? behavior been changed to work only for Result or it still works with any T: Carrier?
If it is the latter case, then I think it must be documented anywhere.

@Manishearth
Copy link
Member

Yes, I think it works with carrier, but it's unstable.

deferring to nrc who pushed for the carrier stuff iirc

r? @nrc

@rust-highfive rust-highfive assigned nrc and unassigned Manishearth Nov 9, 2016
@KalitaAlexey
Copy link
Contributor

Is ? going to be stabilized without Carrier?

@Manishearth
Copy link
Member

I think it already was? Carrier can be stabilized later.

@nrc
Copy link
Member

nrc commented Nov 9, 2016

Yes, I think it works with carrier, but it's unstable.

This correct

@nrc nrc added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 9, 2016
@nrc
Copy link
Member

nrc commented Nov 9, 2016

@bors: r+ rollup

(The Carrier trait exists, but only for purposes of future compatibility, I don't think it should be advertised/documented)

@bors
Copy link
Contributor

bors commented Nov 9, 2016

📌 Commit 1e9aad7 has been approved by nrc

eddyb added a commit to eddyb/rust that referenced this pull request Nov 10, 2016
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.
bors added a commit that referenced this pull request Nov 10, 2016
Rollup of 5 pull requests

- Successful merges: #37402, #37412, #37661, #37664, #37667
- Failed merges:
@bors bors merged commit 1e9aad7 into rust-lang:master Nov 10, 2016
@brson brson added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Dec 10, 2016
@brson
Copy link
Contributor

brson commented Dec 10, 2016

Reasonable backport.

@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Dec 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants