File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-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,14 @@ impl Path {
15431542 ///
15441543 /// assert_eq!(Some(os_str), path.file_name());
15451544 /// ```
1545+ ///
1546+ /// # Other examples
1547+ ///
1548+ /// ```
1549+ /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.").file_name());
1550+ /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.//").file_name());
1551+ /// assert_eq!(None, Path::new("foo.txt/..").file_name());
1552+ /// ```
15461553 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
15471554 pub fn file_name ( & self ) -> Option < & OsStr > {
15481555 self . components ( ) . next_back ( ) . and_then ( |p| {
You can’t perform that action at this time.
0 commit comments