From 6436ebee2a84820adf77231cead6b5691c8e2744 Mon Sep 17 00:00:00 2001 From: Chris Jefferson Date: Sat, 18 Feb 2017 11:23:51 +0000 Subject: [PATCH] Use expect in Chapter 3, as in Chapter 2 --- src/ch03-02-data-types.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ch03-02-data-types.md b/src/ch03-02-data-types.md index dc367f0a0..f5d9d5ef5 100644 --- a/src/ch03-02-data-types.md +++ b/src/ch03-02-data-types.md @@ -13,7 +13,7 @@ converted a `String` to a numeric type using `parse` in Chapter 2, we must add a type annotation, like this: ```rust -let guess: u32 = "42".parse().unwrap(); +let guess: u32 = "42".parse().expect("Not a number!"); ``` If we don’t add the type annotation here, Rust will display the following @@ -24,7 +24,7 @@ possible type we want to use: error[E0282]: unable to infer enough type information about `_` --> src/main.rs:2:5 | -2 | let guess = "42".parse().unwrap(); +2 | let guess = "42".parse().expect("Not a number!"); | ^^^^^ cannot infer type for `_` | = note: type annotations or generic parameter binding required