diff options
| -rw-r--r-- | src/doc/unstable-book/src/language-features/catch-expr.md | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/doc/unstable-book/src/language-features/catch-expr.md b/src/doc/unstable-book/src/language-features/catch-expr.md index 247333d841a..5295d642aa6 100644 --- a/src/doc/unstable-book/src/language-features/catch-expr.md +++ b/src/doc/unstable-book/src/language-features/catch-expr.md @@ -6,22 +6,24 @@ The tracking issue for this feature is: [#31436] ------------------------ -The `catch_expr` feature adds support for a `catch` expression. The `catch` -expression creates a new scope one can use the `?` operator in. +The `catch_expr` feature adds support for `try` blocks. A `try` +block creates a new scope one can use the `?` operator in. + +```rust,ignore +// This code needs the 2018 edition -```rust #![feature(catch_expr)] use std::num::ParseIntError; -let result: Result<i32, ParseIntError> = do catch { +let result: Result<i32, ParseIntError> = try { "1".parse::<i32>()? + "2".parse::<i32>()? + "3".parse::<i32>()? }; assert_eq!(result, Ok(6)); -let result: Result<i32, ParseIntError> = do catch { +let result: Result<i32, ParseIntError> = try { "1".parse::<i32>()? + "foo".parse::<i32>()? + "3".parse::<i32>()? |
