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:
Andrew Jones
2022-01-28 09:28:04 +00:00
committed by GitHub
parent d1494b5cb6
commit eb266b9be6
5 changed files with 58 additions and 10 deletions
+1 -2
View File
@@ -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,
+33
View File
@@ -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()
)
}