Replace ok().expect() by Result::expect in trait chapter of trpl

This commit is contained in:
Florian Hartwig 2015-11-01 20:40:20 +01:00
parent a5fbb3a25f
commit f7a61678e3

View File

@ -247,7 +247,7 @@ wont have its methods:
[write]: ../std/io/trait.Write.html
```rust,ignore
let mut f = std::fs::File::open("foo.txt").ok().expect("Couldnt open foo.txt");
let mut f = std::fs::File::open("foo.txt").expect("Couldnt open foo.txt");
let buf = b"whatever"; // byte string literal. buf: &[u8; 8]
let result = f.write(buf);
# result.unwrap(); // ignore the error
@ -266,7 +266,7 @@ We need to `use` the `Write` trait first:
```rust,ignore
use std::io::Write;
let mut f = std::fs::File::open("foo.txt").ok().expect("Couldnt open foo.txt");
let mut f = std::fs::File::open("foo.txt").expect("Couldnt open foo.txt");
let buf = b"whatever";
let result = f.write(buf);
# result.unwrap(); // ignore the error