Skip to content

Commit

Permalink
impl Get<u32> for RuntimeFreezeReason/RuntimeHoldReason
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Jan 5, 2024
1 parent b752f74 commit 80c685c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ pub fn expand_outer_freeze_reason(pallet_decls: &[Pallet], scrate: &TokenStream)
const VARIANT_COUNT: u32 = #( #freeze_reason_variants_count )+*;
}

/// Implementation of `Get<u32>` which returns `RuntimeFreezeReason::VARIANT_COUNT`.
impl #scrate::traits::Get<u32> for RuntimeFreezeReason {
fn get() -> u32 {
<RuntimeFreezeReason as #scrate::traits::VariantCount>::VARIANT_COUNT
}
}

#( #conversion_fns )*
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ pub fn expand_outer_hold_reason(pallet_decls: &[Pallet], scrate: &TokenStream) -
const VARIANT_COUNT: u32 = #( #hold_reason_variants_count )+*;
}

/// Implementation of `Get<u32>` which returns `RuntimeHoldReason::VARIANT_COUNT`.
impl #scrate::traits::Get<u32> for RuntimeHoldReason {
fn get() -> u32 {
<RuntimeHoldReason as #scrate::traits::VariantCount>::VARIANT_COUNT
}
}

#( #conversion_fns )*
}
}
2 changes: 1 addition & 1 deletion substrate/frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ pub mod pallet_prelude {
/// the enum:
///
/// ```ignore
/// Copy, Clone, Eq, PartialEq, Encode, Decode, MaxEncodedLen, TypeInfo, RuntimeDebug
/// Copy, Clone, Eq, PartialEq, Encode, Decode, MaxEncodedLen, TypeInfo, RuntimeDebug, CompositeEnumVariantCount
/// ```
///
/// The inverse is also true: if there are any #[derive] attributes present for the enum, then
Expand Down

0 comments on commit 80c685c

Please sign in to comment.