Truncates `self` to [`self.parent`]. Returns `false` and does nothing if [`self.parent`] is [`None`]. Otherwise, returns `true`. [`self.parent`]: Path::parent # Examples ``` use std::path::{Path, PathBuf}; let mut p = PathBuf::from("/spirited/away.rs"); p.pop(); assert_eq!(Path::new("/spirited"), p); p.pop(); assert_eq!(Path::new("/"), p); ```
(&mut self)
| 237 | /// assert_eq!(Path::new("/"), p); |
| 238 | /// ``` |
| 239 | pub fn pop(&mut self) -> bool { |
| 240 | match self.parent().map(|p| p.as_u8_slice().len()) { |
| 241 | Some(len) => { |
| 242 | self.as_mut_vec().truncate(len); |
| 243 | true |
| 244 | } |
| 245 | None => false, |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | impl fmt::Debug for PathBuf { |
no test coverage detected