diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-05-05 09:23:36 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-05-05 09:23:36 +0530 |
| commit | b8fedad89b8ea7af2062a581428e1999bf3dfac7 (patch) | |
| tree | a6280a1553e021db74871c2eeb9f2c09d467ae11 /src/doc/trpl | |
| parent | 435622028f37085819843f4ac8938557501f0468 (diff) | |
| parent | 75a3e29042059c7481358816d22f3a06aae53ba6 (diff) | |
| download | rust-b8fedad89b8ea7af2062a581428e1999bf3dfac7.tar.gz rust-b8fedad89b8ea7af2062a581428e1999bf3dfac7.zip | |
Rollup merge of #25068 - bguiz:patch-3, r=steveklabnik
- `File::open` is for opening a file in read-only mode - `File::create` is for opening a file in write-only mode, which is what we want instead for this example to make sense
Diffstat (limited to 'src/doc/trpl')
| -rw-r--r-- | src/doc/trpl/error-handling.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md index e261eb01dba..e4809214bd4 100644 --- a/src/doc/trpl/error-handling.md +++ b/src/doc/trpl/error-handling.md @@ -252,7 +252,7 @@ struct Info { } fn write_info(info: &Info) -> io::Result<()> { - let mut file = File::open("my_best_friends.txt").unwrap(); + let mut file = File::create("my_best_friends.txt").unwrap(); if let Err(e) = writeln!(&mut file, "name: {}", info.name) { return Err(e) @@ -282,7 +282,7 @@ struct Info { } fn write_info(info: &Info) -> io::Result<()> { - let mut file = try!(File::open("my_best_friends.txt")); + let mut file = try!(File::create("my_best_friends.txt")); try!(writeln!(&mut file, "name: {}", info.name)); try!(writeln!(&mut file, "age: {}", info.age)); |
