diff --git a/src/ch09-02-recoverable-errors-with-result.md b/src/ch09-02-recoverable-errors-with-result.md index e2e8475..e5dfc2f 100644 --- a/src/ch09-02-recoverable-errors-with-result.md +++ b/src/ch09-02-recoverable-errors-with-result.md @@ -187,6 +187,7 @@ call `unwrap`. Here's an example: ```rust use std::net::IpAddr; + let home = "127.0.0.1".parse::().unwrap(); ``` @@ -256,7 +257,9 @@ expressions: fn read_username_from_file() -> Result { let mut f = try!(File::open("hello.txt")); let mut s = String::new(); + try!(f.read_to_string(&mut s)); + Ok(s) } ``` @@ -316,7 +319,9 @@ by instead doing: # fn read_username_from_file() -> Result { let mut s = String::new(); + File::open("hello.txt")?.read_to_string(&mut s)?; + Ok(s) } ``` diff --git a/src/ch09-03-to-panic-or-not-to-panic.md b/src/ch09-03-to-panic-or-not-to-panic.md index 45c9e0f..11612bb 100644 --- a/src/ch09-03-to-panic-or-not-to-panic.md +++ b/src/ch09-03-to-panic-or-not-to-panic.md @@ -120,6 +120,7 @@ impl Guess { if value < 1 || value > 100 { panic!("Guess value must be between 1 and 100, got {}.", value); } + Guess { value: value, }