Fix the unstable book

I ignored the code block as I didn't see a way to run the doctest in 2018 -- I noticed the edition guide is also not testing its 2018 code snippits.
This commit is contained in:
Scott McMurray 2018-07-21 23:23:15 -07:00
parent 9e64ce1799
commit ef198867a7

View File

@ -6,22 +6,24 @@ The tracking issue for this feature is: [#31436]
------------------------ ------------------------
The `catch_expr` feature adds support for a `catch` expression. The `catch` The `catch_expr` feature adds support for `try` blocks. A `try`
expression creates a new scope one can use the `?` operator in. block creates a new scope one can use the `?` operator in.
```rust,ignore
// This code needs the 2018 edition
```rust
#![feature(catch_expr)] #![feature(catch_expr)]
use std::num::ParseIntError; use std::num::ParseIntError;
let result: Result<i32, ParseIntError> = do catch { let result: Result<i32, ParseIntError> = try {
"1".parse::<i32>()? "1".parse::<i32>()?
+ "2".parse::<i32>()? + "2".parse::<i32>()?
+ "3".parse::<i32>()? + "3".parse::<i32>()?
}; };
assert_eq!(result, Ok(6)); assert_eq!(result, Ok(6));
let result: Result<i32, ParseIntError> = do catch { let result: Result<i32, ParseIntError> = try {
"1".parse::<i32>()? "1".parse::<i32>()?
+ "foo".parse::<i32>()? + "foo".parse::<i32>()?
+ "3".parse::<i32>()? + "3".parse::<i32>()?