Skip to content

Commit

Permalink
Replace ok().expect() by Result::expect in trait chapter of trpl
Browse files Browse the repository at this point in the history
  • Loading branch information
fhartwig committed Nov 1, 2015
1 parent a5fbb3a commit f7a6167
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/doc/trpl/traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f7a6167

Please sign in to comment.