Skip to content

Commit

Permalink
Rollup merge of #69284 - jumbatm:openoptions-create-doc, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Reword OpenOptions::{create, create_new} doc.

Closes #69254.

Currently, the doc comment for `fs::OpenOptions::create` doesn't mention its behaviour when opening an existing file, and `fs::OpenOptions::create_new`'s doc comment is worded in a way that doesn't make it clear that it actually _fails_ if the file already exists, not overwrite the existing file with a new one.

This PR addresses addresses this by rewording the doc comments to be more explicit.

r? @GuillaumeGomez
  • Loading branch information
Dylan-DPC authored Feb 19, 2020
2 parents 61d3b6d + c899dc1 commit a97f354
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,7 @@ impl OpenOptions {
self
}

/// Sets the option for creating a new file.
///
/// This option indicates whether a new file will be created if the file
/// does not yet already exist.
/// Sets the option to create a new file, or open it if it already exists.
///
/// In order for the file to be created, [`write`] or [`append`] access must
/// be used.
Expand All @@ -868,11 +865,10 @@ impl OpenOptions {
self
}

/// Sets the option to always create a new file.
/// Sets the option to create a new file, failing if it already exists.
///
/// This option indicates whether a new file will be created.
/// No file is allowed to exist at the target location, also no (dangling)
/// symlink.
/// No file is allowed to exist at the target location, also no (dangling) symlink. In this
/// way, if the call succeeds, the file returned is guaranteed to be new.
///
/// This option is useful because it is atomic. Otherwise between checking
/// whether a file exists and creating a new one, the file may have been
Expand Down

0 comments on commit a97f354

Please sign in to comment.