Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8fa3f60

Browse files
committedMay 21, 2024
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.
1 parent 09663fe commit 8fa3f60

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
@@ -2310,6 +2310,9 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
23102310
/// If this function returns an error, some of the parent components might have
23112311
/// been created already.
23122312
///
2313+
/// If the empty path is passed to this function, it always succeeds without
2314+
/// creating any directories.
2315+
///
23132316
/// # Platform-specific behavior
23142317
///
23152318
/// This function currently corresponds to multiple calls to the `mkdir`

0 commit comments

Comments
 (0)
Failed to load comments.