MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / pop

Method pop

euralios_std/src/path.rs:239–247  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
250impl fmt::Debug for PathBuf {

Callers 4

mainFunction · 0.80
nextMethod · 0.80
canonicalizeFunction · 0.80
read_lineMethod · 0.80

Calls 5

parentMethod · 0.80
as_u8_sliceMethod · 0.80
truncateMethod · 0.80
as_mut_vecMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected