summary refs log tree commit diff
path: root/src/libstd/path.rs
diff options
context:
space:
mode:
authorggomez <guillaume1.gomez@gmail.com>2016-07-05 11:36:43 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-06 01:26:24 +0200
commit0d78f6b40f0cf8650bf3c40b65fa774533054d12 (patch)
tree43a5d8fe209033c0955f0bde9ac9666a4eccf985 /src/libstd/path.rs
parent0f4c4f8c2910d717044a041039a1a1aa914ff59e (diff)
downloadrust-0d78f6b40f0cf8650bf3c40b65fa774533054d12.tar.gz
rust-0d78f6b40f0cf8650bf3c40b65fa774533054d12.zip
Fix `std::path::Path::file_name()` doc
Diffstat (limited to 'src/libstd/path.rs')
-rw-r--r--src/libstd/path.rs14
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| {