#type-name #proc-macro #conversion #convert

proc-macro-type-name

Convert Rust field names (snake case) to type names (pascal case) using proc_macro2 identifiers

1 unstable release

0.1.0 Feb 27, 2023

#1450 in Procedural macros

Download history 4/week @ 2023-11-20 7/week @ 2023-12-11 32/week @ 2023-12-18 4/week @ 2024-01-01 15/week @ 2024-02-19 41/week @ 2024-02-26 13/week @ 2024-03-04

69 downloads per month

MIT/Apache

7KB
91 lines

proc-macro-type-name

Convert Rust field names (snake case) to type names (pascal case) using proc_macro2 identifiers.

Example

use proc_macro_type_name::ToTypeName;

let ident: proc_macro2::Indent = Ident::new("foo_bar", Span::call_site());
let type_ident = (&ident).to_type_ident(ident.span());

assert_eq!(type_ident.to_string(), "FooBar".to_owned());

quote! {
    enum #type_ident {}
}

lib.rs:

proc-macro-type-name

Convert Rust field names (snake case) to type names (pascal case) using proc_macro2 identifiers.

Example

use proc_macro_type_name::ToTypeName;

let ident: proc_macro2::Indent = Ident::new("foo_bar", Span::call_site());
let type_ident = (&ident).to_type_ident(ident.span());

assert_eq!(type_ident.to_string(), "FooBar".to_owned());

quote! {
    enum #type_ident {}
}

Dependencies

~64KB