[][src]Crate path_macro

This library provides path!, a macro to join path components using /.

Python's pathlib.Path provides an egonomic API for composing paths out of path components by overloading the division operator:

$ python3
>>> from pathlib import Path
>>> p = Path('a')
>>> q = p / 'b' / 'c'
>>> q

The path! macro provides a similar API for Rust paths without having to overload Path or PathBuf.

use std::path::Path;

use path_macro::path;

let p = path!(Path::new("a") / "x" / "y" / "z");

assert_eq!(p, Path::new("a/x/y/z"));

assert_eq!(p, Path::new("a\\x\\y\\z"));