diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-05-19 18:47:13 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-05-19 18:47:13 +0530 |
| commit | 392576b6d8f513a5deab2b8ce2c4560d1dc0dba8 (patch) | |
| tree | 3dcf524cb026364b538b57672d326e9e334d17c6 | |
| parent | fddd89319ddd76e6da89c4b273ded30d9d89f92a (diff) | |
| parent | a10d243dd46e84813819cca140a72ad9fcff951d (diff) | |
| download | rust-392576b6d8f513a5deab2b8ce2c4560d1dc0dba8.tar.gz rust-392576b6d8f513a5deab2b8ce2c4560d1dc0dba8.zip | |
Rollup merge of #25512 - peferron:doc-traits-error-fix, r=alexcrichton
The source code snippet uses `"whatever".as_bytes()` but the compilation error message uses `b"whatever"`. Both should be consistent with each other. r? @steveklabnik
| -rw-r--r-- | src/doc/trpl/traits.md | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/doc/trpl/traits.md b/src/doc/trpl/traits.md index 889205ad5d8..c82f0405598 100644 --- a/src/doc/trpl/traits.md +++ b/src/doc/trpl/traits.md @@ -183,7 +183,8 @@ won’t have its methods: ```rust,ignore let mut f = std::fs::File::open("foo.txt").ok().expect("Couldn’t open foo.txt"); -let result = f.write("whatever".as_bytes()); +let buf = b"whatever"; // byte string literal. buf: &[u8; 8] +let result = f.write(buf); # result.unwrap(); // ignore the error ``` @@ -191,9 +192,8 @@ Here’s the error: ```text error: type `std::fs::File` does not implement any method in scope named `write` - -let result = f.write(b"whatever"); - ^~~~~~~~~~~~~~~~~~ +let result = f.write(buf); + ^~~~~~~~~~ ``` We need to `use` the `Write` trait first: @@ -202,7 +202,8 @@ We need to `use` the `Write` trait first: use std::io::Write; let mut f = std::fs::File::open("foo.txt").ok().expect("Couldn’t open foo.txt"); -let result = f.write("whatever".as_bytes()); +let buf = b"whatever"; +let result = f.write(buf); # result.unwrap(); // ignore the error ``` |
