diff --git a/src/path/pathbuf.rs b/src/path/pathbuf.rs index 2d6ba19..b3a8d0a 100644 --- a/src/path/pathbuf.rs +++ b/src/path/pathbuf.rs @@ -64,6 +64,30 @@ impl PathBuf { pub fn new() -> PathBuf { std::path::PathBuf::new().into() } + + /// Truncates `self` to [`self.parent`]. + /// + /// Returns `false` and does nothing if [`self.parent`] is [`None`]. + /// Otherwise, returns `true`. + /// + /// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None + /// [`self.parent`]: struct.PathBuf.html#method.parent + /// + /// # Examples + /// + /// ``` + /// use async_std::path::{Path, PathBuf}; + /// + /// let mut p = PathBuf::from("/test/test.rs"); + /// + /// p.pop(); + /// assert_eq!(Path::new("/test"), p.as_ref()); + /// p.pop(); + /// assert_eq!(Path::new("/"), p.as_ref()); + /// ``` + pub fn pop(&mut self) -> bool { + self.inner.pop() + } } impl From for PathBuf {