pathtrim
pathtrim
is a simple, yet powerful Rust library that helps you obtain the last n parts of a filesystem path. It provides a seamless way to work with paths in a cross-platform manner, making it a great choice for projects that need to run on different systems like Unix, macOS, and Windows.
With pathtrim
, you get a clean and intuitive API for handling path trimming, out-of-the-box support for different platforms, and the confidence that comes with strong safety guarantees, thanks to the use of Rust's features and ecosystem.
💡 Features
- Obtain the last n components of a path with just a line of code.
- Cross-platform: works seamlessly on Unix, macOS, and Windows.
- Built upon the powerful std::path module.
- Highly configurable, with a simple and easy-to-understand API.
🚀 Getting Started
Add this to your Cargo.toml
:
[]
= "0.2.0"
And then import the trait in the file where you want to use it:
use Path;
use TrimmablePath;
Examples
Basic Usage
use Path;
use TrimmablePath;
let path = new;
let trimmed = path.trim_to_nth.unwrap;
assert_eq!;
Different Platforms
Unix:
use Path;
use TrimmablePath;
let path = new;
let trimmed = path.trim_to_nth.unwrap;
assert_eq!;
Windows:
use Path;
use TrimmablePath;
let path = new;
let trimmed = path.trim_to_nth.unwrap;
assert_eq!;
Edge Cases
use Path;
use TrimmablePath;
let path = new;
let trimmed = path.trim_to_nth;
assert!;
📚 Further Reading
To gain a deeper understanding of path components and various related APIs, refer to the official Rust documentation:
License
This project is licensed under the MIT License.