Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Pathx - path utilities for Rust
pathx
is a cross-platform Rust crate offering intiuitive utilities for working with paths. Itโs made to complement std::path
, not replace itโfocusing on operations that purely lexical.
The crate includes functions like join
, relative_to
, is_subpath
, and strip_root
, along with a macro for path templating. These utilities simplify path manipulations without relying on access to the filesystem
Links
crates.io
github repo
Install
Run cargo add pathx
Example
use pathx::{join, join_lossy};
use std::path::Path;
fn main() {
// Joining paths
let base = Path::new("/foo/bar");
let segment = Path::new("../baz");
let result = join(base, segment).unwrap();
println!("{result:?}");
// Joining paths (lossy)
let lossy_result = join_lossy(base, segment);
println!("{lossy_result:?}");
}
More examples are available here.
Feedback and contributions are welcome.
6 posts - 2 participants
๐ท๏ธ Rust_feed