[−][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
PosixPath('a/b/c')
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"); #[cfg(unix)] assert_eq!(p, Path::new("a/x/y/z")); #[cfg(windows)] assert_eq!(p, Path::new("a\\x\\y\\z"));
Macros
path |