diff options
| author | Corey Farwell <coreyf@rwell.org> | 2016-11-14 15:51:15 -0500 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2016-11-14 15:54:40 -0500 |
| commit | af1aa1bccf8029a1db1aaddfc6b8c54ea3dff927 (patch) | |
| tree | 515fb135309a653281d5da527bb6b7ccf855a743 /src/libstd | |
| parent | 766f6e4782994ff9f0b0cad9af9cd63b5a2d0f0d (diff) | |
| download | rust-af1aa1bccf8029a1db1aaddfc6b8c54ea3dff927.tar.gz rust-af1aa1bccf8029a1db1aaddfc6b8c54ea3dff927.zip | |
Update top-level path doc examples to show results.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/path.rs | 23 |
1 files changed, 18 insertions, 5 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<OsStr> for PathBuf { /// /// ``` /// 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"))); /// ``` -/// #[stable(feature = "rust1", since = "1.0.0")] pub struct Path { inner: OsStr, |
