diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2016-02-28 17:38:48 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2016-03-07 14:39:39 -0500 |
| commit | 210dd611aa1bd80ed2f4e663b3c4b87b3cea069a (patch) | |
| tree | ad6c6e804d47524cce05caaf60d22ac8d62d2935 /src/libsyntax/ast.rs | |
| parent | c116ae35cf49b55bd8d82e31f1ba030cf7e63867 (diff) | |
| download | rust-210dd611aa1bd80ed2f4e663b3c4b87b3cea069a.tar.gz rust-210dd611aa1bd80ed2f4e663b3c4b87b3cea069a.zip | |
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
Diffstat (limited to 'src/libsyntax/ast.rs')
| -rw-r--r-- | src/libsyntax/ast.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 0dbfb2c7be6..342ba60e553 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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 |
