use proc_macro2::TokenStream;
use quote::{ToTokens, format_ident, quote};
use syn::{Attribute, Ident};
pub fn to_pascal_case(ident: &Ident) -> Ident {
let s = ident.to_string();
let mut capital = true;
let mut out = String::new();
for c in s.chars() {
if c == '_' {
capital = true;
} else if capital {
out.push(c.to_uppercase().next().unwrap());
capital = false;
} else {
out.push(c);
}
}
format_ident!("{}", out)
}
pub fn attribute_tokens(attrs: &[Attribute]) -> TokenStream {
let mut tokens = quote! {};
for attr in attrs {
attr.to_tokens(&mut tokens);
}
tokens
}