2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-01-31 01:35:33 +00:00

Implemented PathBuf::pop

This commit is contained in:
Wouter Geraedts 2019-10-13 21:20:43 +02:00
parent 71125d5c3b
commit 07f9e48579

View file

@ -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<std::path::PathBuf> for PathBuf {