diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2024-06-16 03:41:57 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-16 03:41:57 -0400 |
| commit | e4bc7deb788f6a33af9aad339861352c827dbee1 (patch) | |
| tree | 114f94bf14c75e31c0400c18d1363cc2c0168416 /library/std/src/fs.rs | |
| parent | cd0c944b0750db887291bc25f20a05f8f31a8195 (diff) | |
| parent | 6add5c99cd1aed9b4c816613770da89470918d7b (diff) | |
| download | rust-e4bc7deb788f6a33af9aad339861352c827dbee1.tar.gz rust-e4bc7deb788f6a33af9aad339861352c827dbee1.zip | |
Rollup merge of #125112 - tbu-:pr_create_dir_all_empty, r=dtolnay
Document behavior of `create_dir_all` wrt. empty path
The behavior makes sense because `Path::new("one_component").parent() == Some(Path::new(""))`, so if one naively wants to create the parent directory for a file to be written, it simply works.
Closes #105108 by documenting the current behavior.
Diffstat (limited to 'library/std/src/fs.rs')
| -rw-r--r-- | library/std/src/fs.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 2132097fde4..cf9a3446522 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -2386,6 +2386,9 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { /// If this function returns an error, some of the parent components might have /// been created already. /// +/// If the empty path is passed to this function, it always succeeds without +/// creating any directories. +/// /// # Platform-specific behavior /// /// This function currently corresponds to multiple calls to the `mkdir` |
