Skip to content

Commit d5d2785

Browse files
committed
docs(std): clarify remove_dir_all errors
1 parent cb9aa8c commit d5d2785

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/std/src/fs.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2284,6 +2284,11 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
22842284
///
22852285
/// See [`fs::remove_file`] and [`fs::remove_dir`].
22862286
///
2287+
/// `remove_dir_all` will fail if `remove_dir` or `remove_file` fail on any constituent paths, including the root path.
2288+
/// As a result, the directory you are deleting must exist, meaning that this function is not idempotent.
2289+
///
2290+
/// Consider ignoring the error if validating the removal is not required for your use case.
2291+
///
22872292
/// [`fs::remove_file`]: remove_file
22882293
/// [`fs::remove_dir`]: remove_dir
22892294
///

0 commit comments

Comments
 (0)