graphics_bindgen/naming.rs
1pub fn snake_to_upper_camel_case(input: &str) -> String {
2 input
3 .split('_')
4 .filter(|s| !s.is_empty())
5 .map(|s| {
6 let mut chars = s.chars();
7 match chars.next() {
8 None => String::new(),
9 Some(first) => first.to_uppercase().collect::<String>() + chars.as_str(),
10 }
11 })
12 .collect()
13}
14
15pub fn snake_ident_to_upper_camel(ident: &syn::Ident) -> syn::Ident {
16 syn::Ident::new(&snake_to_upper_camel_case(&ident.to_string()), ident.span())
17}