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:
parent
71125d5c3b
commit
07f9e48579
1 changed files with 24 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue