prefixes_re/
lib.rs

1//! A procedural macro that allows you to use the `re` attribute to create a `Regex` from a string literal.
2//! Part of the [prefixes](https://crates.io/crates/prefixes) crate.
3
4use proc_macro::TokenStream;
5use quote::quote;
6use syn::{parse_macro_input, LitStr};
7
8#[proc_macro_attribute]
9pub fn re(_: TokenStream, input: TokenStream) -> TokenStream {
10    let input = parse_macro_input!(input as LitStr);
11
12    quote! { ::regex::Regex::new(#input) }.into()
13}