Skip to content

Commit f7a6167

Browse files
committed
Replace ok().expect() by Result::expect in trait chapter of trpl
1 parent a5fbb3a commit f7a6167

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/doc/trpl/traits.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ won’t have its methods:
247247
[write]: ../std/io/trait.Write.html
248248

249249
```rust,ignore
250-
let mut f = std::fs::File::open("foo.txt").ok().expect("Couldn’t open foo.txt");
250+
let mut f = std::fs::File::open("foo.txt").expect("Couldn’t open foo.txt");
251251
let buf = b"whatever"; // byte string literal. buf: &[u8; 8]
252252
let result = f.write(buf);
253253
# result.unwrap(); // ignore the error
@@ -266,7 +266,7 @@ We need to `use` the `Write` trait first:
266266
```rust,ignore
267267
use std::io::Write;
268268
269-
let mut f = std::fs::File::open("foo.txt").ok().expect("Couldn’t open foo.txt");
269+
let mut f = std::fs::File::open("foo.txt").expect("Couldn’t open foo.txt");
270270
let buf = b"whatever";
271271
let result = f.write(buf);
272272
# result.unwrap(); // ignore the error

0 commit comments

Comments
 (0)