File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -1007,6 +1007,30 @@ impl Metadata {
10071007 self . file_type ( ) . is_file ( )
10081008 }
10091009
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+
10101034 /// Returns the size of the file, in bytes, this metadata is for.
10111035 ///
10121036 /// # Examples
Original file line number Diff line number Diff line change @@ -2588,10 +2588,9 @@ impl Path {
25882588 /// assert_eq!(link_path.is_symlink(), true);
25892589 /// assert_eq!(link_path.exists(), false);
25902590 /// ```
2591- #[ unstable( feature = "path_ext" , issue = "none" ) ]
2592- #[ inline]
2591+ #[ unstable( feature = "is_symlink" , issue = "none" ) ]
25932592 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 )
25952594 }
25962595
25972596 /// Converts a [`Box<Path>`](Box) into a [`PathBuf`] without copying or
You can’t perform that action at this time.
0 commit comments