mirror of
https://github.com/Noratrieb/mono-fmt.git
synced 2026-01-17 00:35:05 +01:00
oh yes
This commit is contained in:
parent
83331e5326
commit
ce5aa95a09
4 changed files with 199 additions and 6 deletions
31
mono-fmt-macro/src/lib.rs
Normal file
31
mono-fmt-macro/src/lib.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{
|
||||
parse::{Parse, ParseStream},
|
||||
Expr, parse_macro_input,
|
||||
};
|
||||
|
||||
struct Input {
|
||||
format_str: String,
|
||||
items: Vec<Expr>,
|
||||
}
|
||||
|
||||
impl Parse for Input {
|
||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
||||
let first = input.parse::<syn::LitStr>()?;
|
||||
Ok(Self {
|
||||
format_str: first.value(),
|
||||
items: Vec::new(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[proc_macro]
|
||||
pub fn format_args(tokens: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(tokens as Input);
|
||||
let str = input.format_str;
|
||||
quote! {
|
||||
(mono_fmt::_private::Str(#str),)
|
||||
}
|
||||
.into()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue