Skip to content

Commit

Permalink
Add .write(true) to append and truncate examples
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
remram44 committed Jun 28, 2015
1 parent c1b8bd2 commit 78ec055
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libstd/fs.rs
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 78ec055

Please sign in to comment.