Minor rewriting of std::path::Path::push doc example.

This commit is contained in:
Corey Farwell 2016-11-13 12:57:03 -05:00
parent b6b98eaa40
commit f53d062d42

View file

@ -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 current path
/// path.push("/etc/passwd");
/// assert_eq!(path, PathBuf::from("/etc/passwd"));
/// Pushing an absolute path replaces the existing path:
///
/// ```
/// use std::path::PathBuf;
///
/// 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) {