mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 17:18:32 +03:00
Minor rewriting of std::path::Path::push doc example.
This commit is contained in:
+12
-5
@@ -983,17 +983,24 @@ pub fn as_path(&self) -> &Path {
|
||||
///
|
||||
/// # 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) {
|
||||
|
||||
Reference in New Issue
Block a user