prefixes_uppercase_os/lib.rs
1//! A procedural macro that allows you to use the `OS` attribute to create an `OsString` 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]
9#[allow(non_snake_case)]
10pub fn OS(_: TokenStream, input: TokenStream) -> TokenStream {
11 let input = parse_macro_input!(input as LitStr);
12
13 quote! { ::std::ffi::OsString::from(std::format!(#input)) }.into()
14}