Replace ok().expect() by Result::expect in trait chapter of trpl
This commit is contained in:
parent
a5fbb3a25f
commit
f7a61678e3
@ -247,7 +247,7 @@ won’t have its methods:
|
||||
[write]: ../std/io/trait.Write.html
|
||||
|
||||
```rust,ignore
|
||||
let mut f = std::fs::File::open("foo.txt").ok().expect("Couldn’t open foo.txt");
|
||||
let mut f = std::fs::File::open("foo.txt").expect("Couldn’t 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("Couldn’t open foo.txt");
|
||||
let mut f = std::fs::File::open("foo.txt").expect("Couldn’t open foo.txt");
|
||||
let buf = b"whatever";
|
||||
let result = f.write(buf);
|
||||
# result.unwrap(); // ignore the error
|
||||
|
Loading…
x
Reference in New Issue
Block a user