diff options
| author | Trevor Gross <tmgross@umich.edu> | 2023-04-13 01:03:30 -0400 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2023-04-13 23:36:26 -0400 |
| commit | 9c567fdaee23a0000bf91d3d550b8da4bee44bd6 (patch) | |
| tree | fb9cb4aaef32779ffcff386359e31f0feb39f0b7 | |
| parent | d8fc8192471063c7b72fb2f95f61a9427ab84b86 (diff) | |
| download | rust-9c567fdaee23a0000bf91d3d550b8da4bee44bd6.tar.gz rust-9c567fdaee23a0000bf91d3d550b8da4bee44bd6.zip | |
Update documentation wording on path 'try_exists' functions
| -rw-r--r-- | library/std/src/fs.rs | 7 | ||||
| -rw-r--r-- | library/std/src/path.rs | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index c550378e7d6..82c27312d0f 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -2511,9 +2511,10 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder { /// This function will traverse symbolic links to query information about the /// destination file. In case of broken symbolic links this will return `Ok(false)`. /// -/// As opposed to the [`Path::exists`] method, this one doesn't silently ignore errors -/// unrelated to the path not existing. (E.g. it will return `Err(_)` in case of permission -/// denied on some of the parent directories.) +/// As opposed to the [`Path::exists`] method, this will only return `Ok(true)` or `Ok(false)` +/// if the path was _verified_ to exist or not exist. If its existence can neither be confirmed +/// nor denied, an `Err(_)` will be propagated instead. This can be the case if e.g. listing +/// permission is denied on one of the parent directories. /// /// Note that while this avoids some pitfalls of the `exists()` method, it still can not /// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios diff --git a/library/std/src/path.rs b/library/std/src/path.rs index dbc18f7827e..6aa7ae7ef90 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2844,9 +2844,11 @@ impl Path { /// This function will traverse symbolic links to query information about the /// destination file. In case of broken symbolic links this will return `Ok(false)`. /// - /// As opposed to the [`exists()`] method, this one doesn't silently ignore errors - /// unrelated to the path not existing. (E.g. it will return `Err(_)` in case of permission - /// denied on some of the parent directories.) + /// [`Path::exists()`] only checks whether or not a path was both found and readable. By + /// contrast, `try_exists` will return `Ok(true)` or `Ok(false)`, respectively, if the path + /// was _verified_ to exist or not exist. If its existence can neither be confirmed nor + /// denied, it will propagate an `Err(_)` instead. This can be the case if e.g. listing + /// permission is denied on one of the parent directories. /// /// Note that while this avoids some pitfalls of the `exists()` method, it still can not /// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios |
