-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[RFC] add the ?
postfix operator
#23040
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
Conversation
r? @kmcallister (rust_highfive has picked a reviewer for you, use r? to override) |
Is there a reason for |
ExprParen(P<Expr>), | ||
|
||
/// `expr?` | ||
ExprQuestion(P<Expr>), |
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.
Arguably this could have a better name.
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.
ExprTry?
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.
For what's it's worth I think of ?
as the exception propagation operator.
👍 @japaric you are on a roll here. |
@japaric thanks so much for taking the initiative here! As you point out, we need to have some accepted RFC for this, so @nikomatsakis and I will also work with @glaebhoerl to revise the existing RFC so we can move forward. |
r? @nikomatsakis (to fill the 'no-one assigned' void) |
☔ The latest upstream changes (presumably #24967) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm going to close this PR, not because I don't want it, but because the lack of RFC is still blocking us. Hopefully we'll see motion there soon now that 1.0 is out the door! Thanks @japaric for the PR, in any case. |
DO NOT MERGE NEEDS AN APPROVED RFC
The
?
postfix operator is sugar equivalent to thetry!
macro, but is more amenable to chaining:File::open("foo")?.metadata()?.is_dir()
. Currently the syntax is accepted in two places:x.foo()?
, andfoo()?
But it could be extended to idents:
let x = y?;
orfoo(x?, y?)
.cc @aturon @nikomatsakis