File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1529,8 +1529,7 @@ impl Path {
1529
1529
1530
1530
/// The final component of the path, if it is a normal file.
1531
1531
///
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`.
1534
1533
///
1535
1534
/// # Examples
1536
1535
///
@@ -1543,6 +1542,14 @@ impl Path {
1543
1542
///
1544
1543
/// assert_eq!(Some(os_str), path.file_name());
1545
1544
/// ```
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
+ /// ```
1546
1553
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1547
1554
pub fn file_name ( & self ) -> Option < & OsStr > {
1548
1555
self . components ( ) . next_back ( ) . and_then ( |p| {
You can’t perform that action at this time.
0 commit comments