Crate trail [] [src]

Build cross-platform paths at compile time.


First, add trail to the dependencies section of your Cargo.toml:

trail = "0.1"

Next, add the following snippet to the entry point of your crate ( or

extern crate trail;


You can also use trail! anywhere else an expression is expected. The expanded output is functionally equivelant to calling Path::new with a hard coded literal.

let absolute = &trail!("", "hello", "world");
let relative = &trail!("hello", "world");

if cfg!(windows) {
    assert_eq!(*absolute, Path::new("\\hello\\world"));
    assert_eq!(*relative, Path::new("hello\\world"));
} else {
    assert_eq!(*absolute, Path::new("/hello/world"));
    assert_eq!(*relative, Path::new("hello/world"));



A macro for building a cross-platform Path at compile time.