File tree 1 file changed +7
-5
lines changed
src/doc/unstable-book/src/language-features
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]
6
6
7
7
------------------------
8
8
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
11
14
12
- ``` rust
13
15
#![feature(catch_expr)]
14
16
15
17
use std::num::ParseIntError;
16
18
17
- let result : Result <i32 , ParseIntError > = do catch {
19
+ let result: Result<i32, ParseIntError> = try {
18
20
"1".parse::<i32>()?
19
21
+ "2".parse::<i32>()?
20
22
+ "3".parse::<i32>()?
21
23
};
22
24
assert_eq!(result, Ok(6));
23
25
24
- let result : Result <i32 , ParseIntError > = do catch {
26
+ let result: Result<i32, ParseIntError> = try {
25
27
"1".parse::<i32>()?
26
28
+ "foo".parse::<i32>()?
27
29
+ "3".parse::<i32>()?
You can’t perform that action at this time.
0 commit comments