Browse Source

Prettier map

master
Julio Biason 6 months ago
parent
commit
7803c58e38
  1. 5
      pathextractiontest/src/main.rs

5
pathextractiontest/src/main.rs

@ -1,10 +1,11 @@
use std::ffi::OsStr;
use std::path::Path;
fn extract<'a>(
path: &'a Path,
current_name: Option<&'a str>,
) -> Option<(&'a Path, Option<&'a str>)> {
let name = path.file_name().map(|x| x.to_str()).flatten();
let name = path.file_name().map(OsStr::to_str).flatten();
let parent = path.parent()?;
// println!("path={path:?}, current_name={current_name:?}, parent={parent:?}, name={name:?}");
@ -30,7 +31,7 @@ mod test {
assert_eq!(result.0, Path::new("something"));
assert_eq!(result.1, Some("default"));
}
#[test]
fn child() {
let result = extract(Path::new("something/.run/special/path"), None).unwrap();

Loading…
Cancel
Save