Skip to content

Commit 9c567fd

Browse files
committed
Update documentation wording on path 'try_exists' functions
1 parent d8fc819 commit 9c567fd

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

library/std/src/fs.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -2511,9 +2511,10 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
25112511
/// This function will traverse symbolic links to query information about the
25122512
/// destination file. In case of broken symbolic links this will return `Ok(false)`.
25132513
///
2514-
/// As opposed to the [`Path::exists`] method, this one doesn't silently ignore errors
2515-
/// unrelated to the path not existing. (E.g. it will return `Err(_)` in case of permission
2516-
/// denied on some of the parent directories.)
2514+
/// As opposed to the [`Path::exists`] method, this will only return `Ok(true)` or `Ok(false)`
2515+
/// if the path was _verified_ to exist or not exist. If its existence can neither be confirmed
2516+
/// nor denied, an `Err(_)` will be propagated instead. This can be the case if e.g. listing
2517+
/// permission is denied on one of the parent directories.
25172518
///
25182519
/// Note that while this avoids some pitfalls of the `exists()` method, it still can not
25192520
/// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios

library/std/src/path.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -2844,9 +2844,11 @@ impl Path {
28442844
/// This function will traverse symbolic links to query information about the
28452845
/// destination file. In case of broken symbolic links this will return `Ok(false)`.
28462846
///
2847-
/// As opposed to the [`exists()`] method, this one doesn't silently ignore errors
2848-
/// unrelated to the path not existing. (E.g. it will return `Err(_)` in case of permission
2849-
/// denied on some of the parent directories.)
2847+
/// [`Path::exists()`] only checks whether or not a path was both found and readable. By
2848+
/// contrast, `try_exists` will return `Ok(true)` or `Ok(false)`, respectively, if the path
2849+
/// was _verified_ to exist or not exist. If its existence can neither be confirmed nor
2850+
/// denied, it will propagate an `Err(_)` instead. This can be the case if e.g. listing
2851+
/// permission is denied on one of the parent directories.
28502852
///
28512853
/// Note that while this avoids some pitfalls of the `exists()` method, it still can not
28522854
/// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios

0 commit comments

Comments
 (0)