diff options
| author | bors <bors@rust-lang.org> | 2016-11-16 05:06:30 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-16 05:06:30 -0800 |
| commit | 478c0d161498c9bd0ee89a7b205e7b2f2437f151 (patch) | |
| tree | e97eda83c5cb0791b0fd781422e90600601e2e12 /src/libstd | |
| parent | d88d06448e1ad928d22cf0a511f1edae91b646d5 (diff) | |
| parent | af1aa1bccf8029a1db1aaddfc6b8c54ea3dff927 (diff) | |
| download | rust-478c0d161498c9bd0ee89a7b205e7b2f2437f151.tar.gz rust-478c0d161498c9bd0ee89a7b205e7b2f2437f151.zip | |
Auto merge of #37774 - frewsxcv:path-doc-example, r=brson
Update top-level path doc examples to show results. None
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, |
