1 个不稳定版本
0.1.0 | 2023年2月27日 |
---|
793 在 过程宏
每月 30 次下载
7KB
91 行
proc-macro-type-name
使用 proc_macro2 标识符将 Rust 字段名(snake case)转换为类型名(pascal case)。
示例
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
使用 proc_macro2 标识符将 Rust 字段名(snake case)转换为类型名(pascal case)。
示例
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 {}
}
依赖项
~60KB