pathtrim
When all you need is the last few parts of a path.
This crate implements the TrimmablePath trait on anything that implements AsRef<std::path::Path> so you can easily obtain the last n parts of a path. One good implementor of AsRef<std::path::Path> that comes to mind is std::path::Path
Usage
use Path;
// at the top of your source file
use TrimmablePath;
// TrimmablePath is automatically implemented for all
// std::path::Paths in the module's scope
let path = new;
let trimmed = path.trim_to_nth.unwrap;
assert_eq!;
let trimmed = path.trim_to_nth.unwrap;
assert_eq!;
let trimmed = path.trim_to_nth.unwrap;
assert_eq!;
let trimmed = path.trim_to_nth;
assert!;
let trimmed = path.trim_to_nth;
assert!;
let trimmed = path.trim_to_nth;
assert!;
note: patch version bumps since 1.0.0 are just documentation updates