pathtrim
When all you need is the last few parts of a path.
This crate implements the TrimmablePath trait on std::path::Path so you can easily obtain the last n parts of a path.
Usage
// in Cargo.toml
[dependencies]
pathtrim = "1.0.3"
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