path_normalizer
๐งน A lightweight Rust crate for lexically normalizing paths โ no filesystem access required.
Why?
This crate is useful for scenarios where you need to manipulate or validate paths without relying on the filesystem. It's particularly handy for:
- Virtual Filesystems: When working with in-memory or virtual filesystems, you can't rely on actual paths existing on disk.
- Configuration Parsing: When reading configuration files, you may need to normalize paths specified by users.
- Sandboxed Environments: In environments where filesystem access is restricted, you can still perform path manipulations.
Note: The features of this crate exist in the Rust standard libary (
std
), but only on the nightly toolchain. This crate provides its features but available regardless of Rust toolchain.
โจ Features
- Normalize paths like
"foo/./bar/../baz"
to"foo/baz"
- Works purely on string logic โ doesn't touch the filesystem
- Cross-platform and fast
๐ฆ Installation
Add this to your Cargo.toml
:
[]
= "0.1"
๐ Usage
use PathNormalizeExt;
use Path;
๐ Why Lexical?
Unlike canonicalize()
, this crate doesn't resolve symlinks or check the filesystem. It simply rewrites the path using lexical rules โ making it ideal for virtual paths, config parsing, or sandboxed environments.
๐ License
MIT
Made with โค๏ธ for Rustaceans who like their paths tidy.