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.
This commit is contained in:
Jacob Pratt 2024-06-16 03:41:57 -04:00 committed by GitHub
commit e4bc7deb78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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`