Skip to content

Commit 04e46c2

Browse files
authored
Rollup merge of rust-lang#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 rust-lang#105108 by documenting the current behavior.
2 parents ae7f43e + 8fa3f60 commit 04e46c2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

std/src/fs.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2386,6 +2386,9 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
23862386
/// If this function returns an error, some of the parent components might have
23872387
/// been created already.
23882388
///
2389+
/// If the empty path is passed to this function, it always succeeds without
2390+
/// creating any directories.
2391+
///
23892392
/// # Platform-specific behavior
23902393
///
23912394
/// This function currently corresponds to multiple calls to the `mkdir`

0 commit comments

Comments
 (0)