Crate trail [] [src]

Build cross-platform paths at compile time.

Installation

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

[dependencies]
trail = "0.1"

Next, add the following snippet to the entry point of your crate (lib.rs or main.rs):

#[macro_use]
extern crate trail;

Usage

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"));
}

Macros

trail

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