Pathx - path utilities for Rust

โš“ Rust    ๐Ÿ“… 2025-08-30    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 2      

surdeus

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

Read full topic

๐Ÿท๏ธ Rust_feed