Skip to content

Commit 15a0cdd

Browse files
authored
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
2 parents e7be8a2 + 3e0360f commit 15a0cdd

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

library/std/src/fs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,6 @@ impl Metadata {
10461046
///
10471047
#[cfg_attr(unix, doc = "```no_run")]
10481048
#[cfg_attr(not(unix), doc = "```ignore")]
1049-
/// #![feature(is_symlink)]
10501049
/// use std::fs;
10511050
/// use std::path::Path;
10521051
/// use std::os::unix::fs::symlink;
@@ -1062,7 +1061,7 @@ impl Metadata {
10621061
/// }
10631062
/// ```
10641063
#[must_use]
1065-
#[unstable(feature = "is_symlink", issue = "85748")]
1064+
#[stable(feature = "is_symlink", since = "1.57.0")]
10661065
pub fn is_symlink(&self) -> bool {
10671066
self.file_type().is_symlink()
10681067
}

library/std/src/path.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -2751,7 +2751,7 @@ impl Path {
27512751
fs::metadata(self).map(|m| m.is_dir()).unwrap_or(false)
27522752
}
27532753

2754-
/// Returns true if the path exists on disk and is pointing at a symbolic link.
2754+
/// Returns `true` if the path exists on disk and is pointing at a symbolic link.
27552755
///
27562756
/// This function will not traverse symbolic links.
27572757
/// In case of a broken symbolic link this will also return true.
@@ -2763,7 +2763,6 @@ impl Path {
27632763
///
27642764
#[cfg_attr(unix, doc = "```no_run")]
27652765
#[cfg_attr(not(unix), doc = "```ignore")]
2766-
/// #![feature(is_symlink)]
27672766
/// use std::path::Path;
27682767
/// use std::os::unix::fs::symlink;
27692768
///
@@ -2772,8 +2771,14 @@ impl Path {
27722771
/// assert_eq!(link_path.is_symlink(), true);
27732772
/// assert_eq!(link_path.exists(), false);
27742773
/// ```
2775-
#[unstable(feature = "is_symlink", issue = "85748")]
2774+
///
2775+
/// # See Also
2776+
///
2777+
/// This is a convenience function that coerces errors to false. If you want to
2778+
/// check errors, call [`fs::symlink_metadata`] and handle its [`Result`]. Then call
2779+
/// [`fs::Metadata::is_symlink`] if it was [`Ok`].
27762780
#[must_use]
2781+
#[stable(feature = "is_symlink", since = "1.57.0")]
27772782
pub fn is_symlink(&self) -> bool {
27782783
fs::symlink_metadata(self).map(|m| m.is_symlink()).unwrap_or(false)
27792784
}

0 commit comments

Comments
 (0)