diff options
| author | bors <bors@rust-lang.org> | 2015-06-28 21:37:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-06-28 21:37:07 +0000 |
| commit | 2671e8cee08eb35013dc211286a6765c80b49c29 (patch) | |
| tree | 9051912dcb0a37cb566c5cc5a733ce08fb660376 /src/libstd | |
| parent | c1b8bd2d6fd4a00522635112d3f7b28501552a65 (diff) | |
| parent | 78ec055a148008b6ef9c01ce6fda3c8e6448113d (diff) | |
| download | rust-2671e8cee08eb35013dc211286a6765c80b49c29.tar.gz rust-2671e8cee08eb35013dc211286a6765c80b49c29.zip | |
Auto merge of #26642 - remram44:doc-openoptions-missing-write, r=alexcrichton
Setting append without write doesn't give you a writeable file. Showing it as an example in the docs is confusing at best ([reddit](https://www.reddit.com/r/rust/comments/3bbz8w/why_is_writing_a_file_not_working_for_me/))
Using truncate (O_TRUNC) on a read-only file is an error on POSIX systems ("unspecified"). Note however that using create (O_CREAT) with read-only flags is fine.
Related: #26103 (which IMHO is wrong; saying "append is different than write" when should simply be "append needs write". My vote is to make append imply write)
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 { |
