From af1aa1bccf8029a1db1aaddfc6b8c54ea3dff927 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 14 Nov 2016 15:51:15 -0500 Subject: [PATCH] Update top-level path doc examples to show results. --- src/libstd/path.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 281e2f17ae6..95c8af66425 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -25,11 +25,18 @@ //! //! ```rust //! use std::path::Path; +//! use std::ffi::OsStr; //! //! let path = Path::new("/tmp/foo/bar.txt"); -//! let file = path.file_name(); +//! +//! let parent = path.parent(); +//! assert_eq!(parent, Some(Path::new("/tmp/foo"))); +//! +//! let file_stem = path.file_stem(); +//! assert_eq!(file_stem, Some(OsStr::new("bar"))); +//! //! let extension = path.extension(); -//! let parent_dir = path.parent(); +//! assert_eq!(extension, Some(OsStr::new("txt"))); //! ``` //! //! To build or modify paths, use `PathBuf`: @@ -1319,13 +1326,19 @@ impl AsRef for PathBuf { /// /// ``` /// use std::path::Path; +/// use std::ffi::OsStr; /// /// let path = Path::new("/tmp/foo/bar.txt"); -/// let file = path.file_name(); -/// let extension = path.extension(); -/// let parent_dir = path.parent(); -/// ``` /// +/// let parent = path.parent(); +/// assert_eq!(parent, Some(Path::new("/tmp/foo"))); +/// +/// let file_stem = path.file_stem(); +/// assert_eq!(file_stem, Some(OsStr::new("bar"))); +/// +/// let extension = path.extension(); +/// assert_eq!(extension, Some(OsStr::new("txt"))); +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub struct Path { inner: OsStr,