diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2025-08-30 18:49:48 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-30 18:49:48 -0500 |
| commit | 94893391182869ae62b481437498f3c06b63d77e (patch) | |
| tree | c92b0b9c15a803771e87b41eb0b7637ca62fa5e7 /library/std/src/fs.rs | |
| parent | 523d3999dcd4bbd9a52661a29dbd7351a9c5fb03 (diff) | |
| parent | 0858b14e25eb9ed105ac25ac6ae756c94edc469b (diff) | |
| download | rust-94893391182869ae62b481437498f3c06b63d77e.tar.gz rust-94893391182869ae62b481437498f3c06b63d77e.zip | |
Rollup merge of #144964 - 0xdeafbeef:fix-open-options, r=ibraheemdev
std: clarify `OpenOptions` error for create without write access Fixes rust-lang/rust#140621
Diffstat (limited to 'library/std/src/fs.rs')
| -rw-r--r-- | library/std/src/fs.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 73d70681df1..28b2c7173d3 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1614,6 +1614,10 @@ impl OpenOptions { /// See also [`std::fs::write()`][self::write] for a simple function to /// create a file with some given data. /// + /// # Errors + /// + /// If `.create(true)` is set without `.write(true)` or `.append(true)`, + /// calling [`open`](Self::open) will fail with [`InvalidInput`](io::ErrorKind::InvalidInput) error. /// # Examples /// /// ```no_run @@ -1685,7 +1689,8 @@ impl OpenOptions { /// * [`AlreadyExists`]: `create_new` was specified and the file already /// exists. /// * [`InvalidInput`]: Invalid combinations of open options (truncate - /// without write access, no access mode set, etc.). + /// without write access, create without write or append access, + /// no access mode set, etc.). /// /// The following errors don't match any existing [`io::ErrorKind`] at the moment: /// * One of the directory components of the specified file path |
