Skip to content

Commit

Permalink
Fix std::path::Path::file_name() doc
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 5, 2016
1 parent 0f4c4f8 commit 0d78f6b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -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| {
Expand Down

0 comments on commit 0d78f6b

Please sign in to comment.