diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-07-08 13:14:20 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-07-08 14:46:59 +0530 |
| commit | f4ae98ab8cf47d4713e319f8e7c1f3d11db2c500 (patch) | |
| tree | c13e4e79374b3f1a6d0f89d63b7f33a94ed3e8b3 /src/libstd | |
| parent | 75276f36feb5808d2d66425ae942375c274a7291 (diff) | |
| parent | 0d78f6b40f0cf8650bf3c40b65fa774533054d12 (diff) | |
| download | rust-f4ae98ab8cf47d4713e319f8e7c1f3d11db2c500.tar.gz rust-f4ae98ab8cf47d4713e319f8e7c1f3d11db2c500.zip | |
Rollup merge of #34659 - GuillaumeGomez:path_file_name, r=steveklabnik
Fix `std::path::Path::file_name()` doc Fixes #34632 r? @steveklabnik
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/path.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index ad4cdef6158..2d19561139b 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1529,8 +1529,7 @@ impl Path { /// The final component of the path, if it is a normal file. /// - /// If the path terminates in `.`, `..`, or consists solely of a root of - /// prefix, `file_name` will return `None`. + /// If the path terminates in `..`, `file_name` will return `None`. /// /// # Examples /// @@ -1543,6 +1542,17 @@ impl Path { /// /// assert_eq!(Some(os_str), path.file_name()); /// ``` + /// + /// # Other examples + /// + /// ``` + /// use std::path::Path; + /// use std::ffi::OsStr; + /// + /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.").file_name()); + /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.//").file_name()); + /// assert_eq!(None, Path::new("foo.txt/..").file_name()); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn file_name(&self) -> Option<&OsStr> { self.components().next_back().and_then(|p| { |
