1
Fork 0

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 /// # Examples
/// ///
/// Pushing a relative path extends the existing path:
///
/// ``` /// ```
/// use std::path::PathBuf; /// use std::path::PathBuf;
/// ///
/// let mut path = PathBuf::new(); /// let mut path = PathBuf::from("/tmp");
/// path.push("/tmp");
/// path.push("file.bk"); /// path.push("file.bk");
/// assert_eq!(path, PathBuf::from("/tmp/file.bk")); /// assert_eq!(path, PathBuf::from("/tmp/file.bk"));
/// ```
/// ///
/// // Pushing an absolute path replaces the current path /// Pushing an absolute path replaces the existing path:
/// path.push("/etc/passwd"); ///
/// assert_eq!(path, PathBuf::from("/etc/passwd")); /// ```
/// 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")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn push<P: AsRef<Path>>(&mut self, path: P) { pub fn push<P: AsRef<Path>>(&mut self, path: P) {