diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-10-31 09:20:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-31 09:20:22 +0100 |
| commit | 15a0cddff3a4fa0c66a7689ef3ba615a6d2366e5 (patch) | |
| tree | 1d8e8cd3fd36fa102b911402dca9fd25dd5aaba2 | |
| parent | e7be8a2c074cb2e198160f599a0ed2745665561a (diff) | |
| parent | 3e0360f3d43442b9d78cb1ba777e13a58506bce6 (diff) | |
| download | rust-15a0cddff3a4fa0c66a7689ef3ba615a6d2366e5.tar.gz rust-15a0cddff3a4fa0c66a7689ef3ba615a6d2366e5.zip | |
Rollup merge of #89677 - maxwase:is-symlink-stabilization, r=joshtriplett
Stabilize `is_symlink()` for `Metadata` and `Path` I'm not fully sure about `since` version, correct me if I'm wrong Needs update after stabilization: [cargo-test-support](https://github.com/rust-lang/cargo/blob/8063672238a5b6c3a901c0fc17f3164692d0be85/crates/cargo-test-support/src/paths.rs#L202) Linked issue: #85748
| -rw-r--r-- | library/std/src/fs.rs | 3 | ||||
| -rw-r--r-- | library/std/src/path.rs | 11 |
2 files changed, 9 insertions, 5 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 9f45e89aa75..2b76a411a0f 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1046,7 +1046,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; @@ -1062,7 +1061,7 @@ impl Metadata { /// } /// ``` #[must_use] - #[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 8f00d2260e4..4e547a80258 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2751,7 +2751,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. @@ -2763,7 +2763,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; /// @@ -2772,8 +2771,14 @@ impl Path { /// assert_eq!(link_path.is_symlink(), true); /// assert_eq!(link_path.exists(), false); /// ``` - #[unstable(feature = "is_symlink", issue = "85748")] + /// + /// # 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`]. #[must_use] + #[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) } |
