prefixes-p 0.1.0

Attribute-like macro for creating `Path`s easily. Part of the 'prefixes' suite.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! A procedural macro that allows you to use the `p` attribute to create a `Path` from a string literal.
//! Part of the [prefixes](https://crates.io/crates/prefixes) crate.

use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, LitStr};

#[proc_macro_attribute]
pub fn p(_: TokenStream, input: TokenStream) -> TokenStream {
    let input = parse_macro_input!(input as LitStr);

    quote! { ::std::path::Path::new(#input) }.into()
}