diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2024-05-14 11:40:19 +0200 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2024-05-21 07:56:56 +0200 |
| commit | 6add5c99cd1aed9b4c816613770da89470918d7b (patch) | |
| tree | f03b006209411a6cb690affa3a617b57502bcc1e | |
| parent | 58426f4a5b69d10db1b0ffa017bac25f1b2e801e (diff) | |
| download | rust-6add5c99cd1aed9b4c816613770da89470918d7b.tar.gz rust-6add5c99cd1aed9b4c816613770da89470918d7b.zip | |
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.
| -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 77e94365b08..5d78b9611a0 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -2310,6 +2310,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` |
