mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-23 13:08:01 +00:00
Only convert struct names to camel case for Call variant structs (#412)
* Only convert struct names to camel case for `Call` variant structs * Use Cow for transform fn * Use as_ref
This commit is contained in:
@@ -22,7 +22,6 @@ use super::{
|
||||
TypeParameter,
|
||||
TypePath,
|
||||
};
|
||||
use heck::CamelCase as _;
|
||||
use proc_macro2::TokenStream;
|
||||
use proc_macro_error::abort_call_site;
|
||||
use quote::{
|
||||
@@ -85,7 +84,7 @@ impl CompositeDef {
|
||||
}
|
||||
}
|
||||
|
||||
let name = format_ident!("{}", ident.to_camel_case());
|
||||
let name = format_ident!("{}", ident);
|
||||
|
||||
Self {
|
||||
name,
|
||||
|
||||
@@ -853,3 +853,36 @@ fn modules() {
|
||||
.to_string()
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dont_force_struct_names_camel_case() {
|
||||
#[allow(unused)]
|
||||
#[derive(TypeInfo)]
|
||||
struct AB;
|
||||
|
||||
let mut registry = Registry::new();
|
||||
registry.register_type(&meta_type::<AB>());
|
||||
let portable_types: PortableRegistry = registry.into();
|
||||
|
||||
let type_gen = TypeGenerator::new(
|
||||
&portable_types,
|
||||
"root",
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
);
|
||||
let types = type_gen.generate_types_mod();
|
||||
let tests_mod = get_mod(&types, MOD_PATH).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
tests_mod.into_token_stream().to_string(),
|
||||
quote! {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt::codec::Encode, ::subxt::codec::Decode, Debug)]
|
||||
pub struct AB;
|
||||
}
|
||||
}
|
||||
.to_string()
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user