Skip to content

Commit ce30232

Browse files
authored
Rollup merge of #110266 - tgross35:try-exists-wording, r=jyn514
Update documentation wording on path 'try_exists' functions Just eliminate the quadruple negation in `doesn't silently ignore errors unrelated to ... not existing.`
2 parents fff8503 + 9c567fd commit ce30232

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
@@ -2515,9 +2515,10 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
25152515
/// This function will traverse symbolic links to query information about the
25162516
/// destination file. In case of broken symbolic links this will return `Ok(false)`.
25172517
///
2518-
/// As opposed to the [`Path::exists`] method, this one doesn't silently ignore errors
2519-
/// unrelated to the path not existing. (E.g. it will return `Err(_)` in case of permission
2520-
/// denied on some of the parent directories.)
2518+
/// As opposed to the [`Path::exists`] method, this will only return `Ok(true)` or `Ok(false)`
2519+
/// if the path was _verified_ to exist or not exist. If its existence can neither be confirmed
2520+
/// nor denied, an `Err(_)` will be propagated instead. This can be the case if e.g. listing
2521+
/// permission is denied on one of the parent directories.
25212522
///
25222523
/// Note that while this avoids some pitfalls of the `exists()` method, it still can not
25232524
/// 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)