Skip to content

Commit 07f9e48

Browse files
committed
Implemented PathBuf::pop
1 parent 71125d5 commit 07f9e48

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/path/pathbuf.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,30 @@ impl PathBuf {
6464
pub fn new() -> PathBuf {
6565
std::path::PathBuf::new().into()
6666
}
67+
68+
/// Truncates `self` to [`self.parent`].
69+
///
70+
/// Returns `false` and does nothing if [`self.parent`] is [`None`].
71+
/// Otherwise, returns `true`.
72+
///
73+
/// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None
74+
/// [`self.parent`]: struct.PathBuf.html#method.parent
75+
///
76+
/// # Examples
77+
///
78+
/// ```
79+
/// use async_std::path::{Path, PathBuf};
80+
///
81+
/// let mut p = PathBuf::from("/test/test.rs");
82+
///
83+
/// p.pop();
84+
/// assert_eq!(Path::new("/test"), p.as_ref());
85+
/// p.pop();
86+
/// assert_eq!(Path::new("/"), p.as_ref());
87+
/// ```
88+
pub fn pop(&mut self) -> bool {
89+
self.inner.pop()
90+
}
6791
}
6892

6993
impl From<std::path::PathBuf> for PathBuf {

0 commit comments

Comments
 (0)