diff options
| author | Remi Rampin <remirampin@gmail.com> | 2015-06-28 17:23:53 -0400 |
|---|---|---|
| committer | Remi Rampin <remirampin@gmail.com> | 2015-06-28 17:26:31 -0400 |
| commit | 78ec055a148008b6ef9c01ce6fda3c8e6448113d (patch) | |
| tree | 9051912dcb0a37cb566c5cc5a733ce08fb660376 /src/libstd | |
| parent | c1b8bd2d6fd4a00522635112d3f7b28501552a65 (diff) | |
| download | rust-78ec055a148008b6ef9c01ce6fda3c8e6448113d.tar.gz rust-78ec055a148008b6ef9c01ce6fda3c8e6448113d.zip | |
Add `.write(true)` to append and truncate examples
Setting append without write doesn't give you a writeable file. Showing it as an example in the docs is confusing at best. Using truncate on a read-only file is an error on POSIX systems (note however that using create with read-only flags is fine).
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/fs.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 2b0f17fb2bb..c2d3d2fb0c8 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -419,7 +419,7 @@ impl OpenOptions { /// ```no_run /// use std::fs::OpenOptions; /// - /// let file = OpenOptions::new().append(true).open("foo.txt"); + /// let file = OpenOptions::new().write(true).append(true).open("foo.txt"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn append(&mut self, append: bool) -> &mut OpenOptions { @@ -436,7 +436,7 @@ impl OpenOptions { /// ```no_run /// use std::fs::OpenOptions; /// - /// let file = OpenOptions::new().truncate(true).open("foo.txt"); + /// let file = OpenOptions::new().write(true).truncate(true).open("foo.txt"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn truncate(&mut self, truncate: bool) -> &mut OpenOptions { |
