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:
@@ -1332,7 +1332,8 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
|
||||
fields.move_map(|x| folder.fold_field(x)),
|
||||
maybe_expr.map(|x| folder.fold_expr(x)))
|
||||
},
|
||||
ExprKind::Paren(ex) => ExprKind::Paren(folder.fold_expr(ex))
|
||||
ExprKind::Paren(ex) => ExprKind::Paren(folder.fold_expr(ex)),
|
||||
ExprKind::Try(ex) => ExprKind::Try(folder.fold_expr(ex)),
|
||||
},
|
||||
span: folder.new_span(span),
|
||||
attrs: attrs.map_thin_attrs(|v| fold_attrs(v, folder)),
|
||||
|
||||
Reference in New Issue
Block a user