macro_rules! err {
($( $tok:ident ).+ : $fstr:literal$(,)? $( $arg:expr ),*) => {
err!([error] $($tok).+ : $fstr, $($arg),*)
};
([ $level:ident ] $( $tok:ident ).+ : $fstr:literal$(,)? $( $arg:expr ),*) => {
$($tok).+.span().unwrap().$level(format!($fstr, $($arg),*)).emit();
};
}
fn keccak_key(ident: &syn::Ident) -> proc_macro2::TokenStream {
let key = syn::parse_str::<syn::Expr>(&format!(
"{:?}",
tiny_keccak::keccak256(ident.to_string().as_bytes())
))
.unwrap();
quote! { #key }
}
macro_rules! format_ident {
($fmt_str:literal, $($fmt_arg:expr),+) => {
syn::Ident::new(&format!($fmt_str, $($fmt_arg),+), proc_macro2::Span::call_site())
}
}