Skip to content

Commit f85d231

Browse files
committed
clarify documentation of remove_dir errors
remove_dir will error if the path doesn't exist or isn't a directory. It's useful to clarify that this is "remove dir or fail" not "remove dir if it exists". I don't think this belongs in the title. "Removes an existing, empty directory" is strangely worded-- there's no such thing as a non-existing directory. Better to just say explicitly it will return an error.
1 parent f50f1c8 commit f85d231

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/std/src/fs.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
19911991
DirBuilder::new().recursive(true).create(path.as_ref())
19921992
}
19931993

1994-
/// Removes an existing, empty directory.
1994+
/// Removes an empty directory.
19951995
///
19961996
/// # Platform-specific behavior
19971997
///
@@ -2006,6 +2006,8 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
20062006
/// This function will return an error in the following situations, but is not
20072007
/// limited to just these cases:
20082008
///
2009+
/// * `path` doesn't exist.
2010+
/// * `path` isn't a directory.
20092011
/// * The user lacks permissions to remove the directory at the provided `path`.
20102012
/// * The directory isn't empty.
20112013
///

0 commit comments

Comments
 (0)