@@ -2592,6 +2592,32 @@ impl Path {
25922592 fs:: metadata ( self ) . map ( |m| m. is_dir ( ) ) . unwrap_or ( false )
25932593 }
25942594
2595+ /// Returns true if the path exists on disk and is pointing at a symbolic link.
2596+ ///
2597+ /// This function will not traverse symbolic links.
2598+ /// In case of a broken symbolic link this will also return true.
2599+ ///
2600+ /// If you cannot access the directory containing the file, e.g., because of a
2601+ /// permission error, this will return false.
2602+ ///
2603+ /// # Examples
2604+ ///
2605+ #[ cfg_attr( unix, doc = "```no_run" ) ]
2606+ #[ cfg_attr( not( unix) , doc = "```ignore" ) ]
2607+ /// #![feature(is_symlink)]
2608+ /// use std::path::Path;
2609+ /// use std::os::unix::fs::symlink;
2610+ ///
2611+ /// let link_path = Path::new("link");
2612+ /// symlink("/origin_does_not_exists/", link_path).unwrap();
2613+ /// assert_eq!(link_path.is_symlink(), true);
2614+ /// assert_eq!(link_path.exists(), false);
2615+ /// ```
2616+ #[ unstable( feature = "is_symlink" , issue = "85748" ) ]
2617+ pub fn is_symlink ( & self ) -> bool {
2618+ fs:: symlink_metadata ( self ) . map ( |m| m. is_symlink ( ) ) . unwrap_or ( false )
2619+ }
2620+
25952621 /// Converts a [`Box<Path>`](Box) into a [`PathBuf`] without copying or
25962622 /// allocating.
25972623 #[ stable( feature = "into_boxed_path" , since = "1.20.0" ) ]
0 commit comments