File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
src/doc/unstable-book/src/language-features Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -6,22 +6,24 @@ The tracking issue for this feature is: [#31436]
66
77------------------------
88
9- The ` catch_expr ` feature adds support for a ` catch ` expression. The ` catch `
10- expression creates a new scope one can use the ` ? ` operator in.
9+ The ` catch_expr ` feature adds support for ` try ` blocks. A ` try `
10+ block creates a new scope one can use the ` ? ` operator in.
11+
12+ ``` rust,ignore
13+ // This code needs the 2018 edition
1114
12- ``` rust
1315#![feature(catch_expr)]
1416
1517use std::num::ParseIntError;
1618
17- let result : Result <i32 , ParseIntError > = do catch {
19+ let result: Result<i32, ParseIntError> = try {
1820 "1".parse::<i32>()?
1921 + "2".parse::<i32>()?
2022 + "3".parse::<i32>()?
2123};
2224assert_eq!(result, Ok(6));
2325
24- let result : Result <i32 , ParseIntError > = do catch {
26+ let result: Result<i32, ParseIntError> = try {
2527 "1".parse::<i32>()?
2628 + "foo".parse::<i32>()?
2729 + "3".parse::<i32>()?
You can’t perform that action at this time.
0 commit comments