File tree 2 files changed +26
-3
lines changed
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -1007,6 +1007,30 @@ impl Metadata {
1007
1007
self . file_type ( ) . is_file ( )
1008
1008
}
1009
1009
1010
+ /// Returns `true` if this metadata is for a symbolic link file.
1011
+ ///
1012
+ /// # Examples
1013
+ ///
1014
+ /// ```no_run
1015
+ /// use std::fs;
1016
+ /// use std::path::Path;
1017
+ /// use std::os::unix::fs::symlink;
1018
+ ///
1019
+ /// fn main() -> std::io::Result<()> {
1020
+ /// let link_path = Path::new("/link");
1021
+ /// symlink("/origin_does_not_exists/", link_path)?;
1022
+ ///
1023
+ /// let metadata = fs::symlink_metadata(link_path)?;
1024
+ ///
1025
+ /// assert!(metadata.is_symlink());
1026
+ /// Ok(())
1027
+ /// }
1028
+ /// ```
1029
+ #[ unstable( feature = "is_symlink" , issue = "none" ) ]
1030
+ pub fn is_symlink ( & self ) -> bool {
1031
+ self . file_type ( ) . is_symlink ( )
1032
+ }
1033
+
1010
1034
/// Returns the size of the file, in bytes, this metadata is for.
1011
1035
///
1012
1036
/// # Examples
Original file line number Diff line number Diff line change @@ -2588,10 +2588,9 @@ impl Path {
2588
2588
/// assert_eq!(link_path.is_symlink(), true);
2589
2589
/// assert_eq!(link_path.exists(), false);
2590
2590
/// ```
2591
- #[ unstable( feature = "path_ext" , issue = "none" ) ]
2592
- #[ inline]
2591
+ #[ unstable( feature = "is_symlink" , issue = "none" ) ]
2593
2592
pub fn is_symlink ( & self ) -> bool {
2594
- fs:: symlink_metadata ( self ) . is_ok ( )
2593
+ fs:: symlink_metadata ( self ) . map ( |m| m . is_symlink ( ) ) . unwrap_or ( false )
2595
2594
}
2596
2595
2597
2596
/// Converts a [`Box<Path>`](Box) into a [`PathBuf`] without copying or
You can’t perform that action at this time.
0 commit comments