implement the ? operator
The `?` postfix operator is sugar equivalent to the try! macro, but is more amenable to chaining:
`File::open("foo")?.metadata()?.is_dir()`.
`?` is accepted on any *expression* that can return a `Result`, e.g. `x()?`, `y!()?`, `{z}?`,
`(w)?`, etc. And binds more tightly than unary operators, e.g. `!x?` is parsed as `!(x?)`.
cc #31436
This commit is contained in:
@@ -1022,6 +1022,9 @@ pub enum ExprKind {
|
||||
|
||||
/// No-op: used solely so we can pretty-print faithfully
|
||||
Paren(P<Expr>),
|
||||
|
||||
/// `expr?`
|
||||
Try(P<Expr>),
|
||||
}
|
||||
|
||||
/// The explicit Self type in a "qualified path". The actual
|
||||
|
||||
Reference in New Issue
Block a user