Minor rewriting of std::path::Path::push
doc example.
This commit is contained in:
parent
b6b98eaa40
commit
f53d062d42
1 changed files with 12 additions and 5 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue