From 55663a76f4cb9c3fe5c9641b9ab84d19806c33b9 Mon Sep 17 00:00:00 2001 From: Maxwase Date: Fri, 8 Oct 2021 22:17:33 +0300 Subject: [PATCH 1/2] Stabilize `is_symlink()` for `Metadata` and `Path` --- library/std/src/fs.rs | 3 +-- library/std/src/path.rs | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index e999c84f80d47..a2ee6e9af72f9 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1021,7 +1021,6 @@ impl Metadata { /// #[cfg_attr(unix, doc = "```no_run")] #[cfg_attr(not(unix), doc = "```ignore")] - /// #![feature(is_symlink)] /// use std::fs; /// use std::path::Path; /// use std::os::unix::fs::symlink; @@ -1036,7 +1035,7 @@ impl Metadata { /// Ok(()) /// } /// ``` - #[unstable(feature = "is_symlink", issue = "85748")] + #[stable(feature = "is_symlink", since = "1.57.0")] pub fn is_symlink(&self) -> bool { self.file_type().is_symlink() } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index a45ecf6ea8c63..a5b73c2580be6 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2723,7 +2723,7 @@ impl Path { fs::metadata(self).map(|m| m.is_dir()).unwrap_or(false) } - /// Returns true if the path exists on disk and is pointing at a symbolic link. + /// Returns `true` if the path exists on disk and is pointing at a symbolic link. /// /// This function will not traverse symbolic links. /// In case of a broken symbolic link this will also return true. @@ -2735,7 +2735,6 @@ impl Path { /// #[cfg_attr(unix, doc = "```no_run")] #[cfg_attr(not(unix), doc = "```ignore")] - /// #![feature(is_symlink)] /// use std::path::Path; /// use std::os::unix::fs::symlink; /// @@ -2744,7 +2743,7 @@ impl Path { /// assert_eq!(link_path.is_symlink(), true); /// assert_eq!(link_path.exists(), false); /// ``` - #[unstable(feature = "is_symlink", issue = "85748")] + #[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) } From 36e050b85f5fc9acd27ff5e8cda57a36070f43e2 Mon Sep 17 00:00:00 2001 From: Max Wase Date: Tue, 12 Oct 2021 08:01:24 +0300 Subject: [PATCH 2/2] Update library/std/src/path.rs Co-authored-by: Jane Lusby --- library/std/src/path.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/std/src/path.rs b/library/std/src/path.rs index a5b73c2580be6..4a0df91521268 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -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)