Skip to content

Commit

Permalink
Document behavior of create_dir_all wrt. empty path
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tbu- committed May 21, 2024
1 parent 58426f4 commit 6add5c9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit 6add5c9

Please sign in to comment.