diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-11-10 10:51:48 -0500 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-11-10 10:51:48 -0500 |
| commit | a39daf95f30639bbec33eddfd7532b5af7c5c200 (patch) | |
| tree | f251c105a1a74c8d325c88125909d006be583401 /src/libstd | |
| parent | 0d04a515170e22d01720df332817649c4470fd3e (diff) | |
| parent | 621e259b78fb992745c3cf194e28be5a8610a97c (diff) | |
| download | rust-a39daf95f30639bbec33eddfd7532b5af7c5c200.tar.gz rust-a39daf95f30639bbec33eddfd7532b5af7c5c200.zip | |
Rollup merge of #29708 - Ryman:pathdoc, r=steveklabnik
r? @steveklabnik
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/path.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index b9a58a11764..6b5e16ae113 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1013,6 +1013,21 @@ impl PathBuf { /// * if `path` has a root but no prefix (e.g. `\windows`), it /// replaces everything except for the prefix (if any) of `self`. /// * if `path` has a prefix but no root, it replaces `self`. + /// + /// # Examples + /// + /// ``` + /// use std::path::PathBuf; + /// + /// let mut path = PathBuf::new(); + /// path.push("/tmp"); + /// path.push("file.bk"); + /// assert_eq!(path, PathBuf::from("/tmp/file.bk")); + /// + /// // Pushing an absolute path replaces the current path + /// path.push("/etc/passwd"); + /// assert_eq!(path, PathBuf::from("/etc/passwd")); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn push<P: AsRef<Path>>(&mut self, path: P) { self._push(path.as_ref()) |
