We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
catch_expr
1 parent 0c97d6c commit d1f4993Copy full SHA for d1f4993
src/doc/unstable-book/src/language-features/catch-expr.md
@@ -5,3 +5,26 @@ The tracking issue for this feature is: [#31436]
5
[#31436]: https://github.com/rust-lang/rust/issues/31436
6
7
------------------------
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.
11
12
+```rust
13
+#![feature(catch_expr)]
14
15
+use std::num::ParseIntError;
16
17
+let result: Result<i32, ParseIntError> = do catch {
18
+ Ok("1".parse::<i32>()?
19
+ + "2".parse::<i32>()?
20
+ + "3".parse::<i32>()?)
21
+};
22
+assert_eq!(result, Ok(6));
23
24
25
26
+ + "foo".parse::<i32>()?
27
28
29
+assert!(result.is_err());
30
+```
0 commit comments