diff options
| author | Corey Farwell <coreyf@rwell.org> | 2016-11-13 12:57:03 -0500 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2016-11-13 12:58:55 -0500 |
| commit | f53d062d427f31211ebcb664dc4d7716ef66d8d8 (patch) | |
| tree | 57f07724423b7af35ed35ce38d1a5ee5cd479cb9 /src/libstd/path.rs | |
| parent | b6b98eaa40d2c81890cbeb31258aadb238f07279 (diff) | |
| download | rust-f53d062d427f31211ebcb664dc4d7716ef66d8d8.tar.gz rust-f53d062d427f31211ebcb664dc4d7716ef66d8d8.zip | |
Minor rewriting of `std::path::Path::push` doc example.
Diffstat (limited to 'src/libstd/path.rs')
| -rw-r--r-- | src/libstd/path.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index bb6883236e8..281e2f17ae6 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -983,17 +983,24 @@ impl PathBuf { /// /// # Examples /// + /// Pushing a relative path extends the existing path: + /// /// ``` /// use std::path::PathBuf; /// - /// let mut path = PathBuf::new(); - /// path.push("/tmp"); + /// let mut path = PathBuf::from("/tmp"); /// path.push("file.bk"); /// assert_eq!(path, PathBuf::from("/tmp/file.bk")); + /// ``` + /// + /// Pushing an absolute path replaces the existing path: + /// + /// ``` + /// use std::path::PathBuf; /// - /// // Pushing an absolute path replaces the current path - /// path.push("/etc/passwd"); - /// assert_eq!(path, PathBuf::from("/etc/passwd")); + /// let mut path = PathBuf::from("/tmp"); + /// path.push("/etc"); + /// assert_eq!(path, PathBuf::from("/etc")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn push<P: AsRef<Path>>(&mut self, path: P) { |
