mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 05:27:56 +00:00
pallet macro: easier syntax for #[pallet::pallet] with struct Pallet<T>(_) (#8091)
This commit is contained in:
committed by
GitHub
parent
2d31af3eb6
commit
e78d139676
@@ -22,6 +22,7 @@ use crate::pallet::Def;
|
||||
/// * Implement OnGenesis on Pallet
|
||||
/// * Implement ModuleErrorMetadata on Pallet
|
||||
/// * declare Module type alias for construct_runtime
|
||||
/// * replace the first field type of `struct Pallet` with `PhantomData` if it is `_`
|
||||
pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
let frame_support = &def.frame_support;
|
||||
let frame_system = &def.frame_system;
|
||||
@@ -41,6 +42,15 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
}
|
||||
};
|
||||
|
||||
// If the first field type is `_` then we replace with `PhantomData`
|
||||
if let Some(field) = pallet_item.fields.iter_mut().next() {
|
||||
if field.ty == syn::parse_quote!(_) {
|
||||
field.ty = syn::parse_quote!(
|
||||
#frame_support::sp_std::marker::PhantomData<(#type_use_gen)>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pallet_item.attrs.push(syn::parse_quote!(
|
||||
#[derive(
|
||||
#frame_support::CloneNoBound,
|
||||
|
||||
Reference in New Issue
Block a user