Update library/std/src/path.rs

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
This commit is contained in:
Max Wase 2021-10-12 08:01:24 +03:00 committed by GitHub
parent 55663a76f4
commit 36e050b85f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2743,6 +2743,12 @@ impl Path {
/// assert_eq!(link_path.is_symlink(), true);
/// assert_eq!(link_path.exists(), false);
/// ```
///
/// # See Also
///
/// This is a convenience function that coerces errors to false. If you want to
/// check errors, call [`fs::symlink_metadata`] and handle its [`Result`]. Then call
/// [`fs::Metadata::is_symlink`] if it was [`Ok`].
#[stable(feature = "is_symlink", since = "1.57.0")]
pub fn is_symlink(&self) -> bool {
fs::symlink_metadata(self).map(|m| m.is_symlink()).unwrap_or(false)