File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1529,8 +1529,7 @@ impl Path {
15291529
15301530 /// The final component of the path, if it is a normal file.
15311531 ///
1532- /// If the path terminates in `.`, `..`, or consists solely of a root of
1533- /// prefix, `file_name` will return `None`.
1532+ /// If the path terminates in `..`, `file_name` will return `None`.
15341533 ///
15351534 /// # Examples
15361535 ///
@@ -1543,6 +1542,17 @@ impl Path {
15431542 ///
15441543 /// assert_eq!(Some(os_str), path.file_name());
15451544 /// ```
1545+ ///
1546+ /// # Other examples
1547+ ///
1548+ /// ```
1549+ /// use std::path::Path;
1550+ /// use std::ffi::OsStr;
1551+ ///
1552+ /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.").file_name());
1553+ /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.//").file_name());
1554+ /// assert_eq!(None, Path::new("foo.txt/..").file_name());
1555+ /// ```
15461556 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
15471557 pub fn file_name ( & self ) -> Option < & OsStr > {
15481558 self . components ( ) . next_back ( ) . and_then ( |p| {
You can’t perform that action at this time.
0 commit comments