Skip to content
Snippets Groups Projects
Unverified Commit 90c91b1e authored by Kian Paimani's avatar Kian Paimani Committed by GitHub
Browse files

allow for `u8` to be used as hold/freeze reason (#5348)

..without needing to provide your own `newtype` around it.  

This will allow `type Reason = u8` to be used as `FreezeReason` and
`HoldReason`, which I think is a nice simplification if one doens't want
to deal with the complications.

At the same time, it is a bit of an anti-pattern.

Putting it out there to check people's vibes.
parent 41a679c4
No related merge requests found
Pipeline #490605 waiting for manual action with stages
in 55 minutes and 6 seconds
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
title: allow for u8 to be used as hold/freeze reason
doc:
- audience: Runtime Dev
description: |
Allows for `u8` type to be configured as `HoldReason` and `FreezeReason`
crates:
- name: frame-support
bump: patch
......@@ -48,6 +48,10 @@ impl VariantCount for () {
const VARIANT_COUNT: u32 = 0;
}
impl VariantCount for u8 {
const VARIANT_COUNT: u32 = 256;
}
/// Adapter for `Get<u32>` to access `VARIANT_COUNT` from `trait pub trait VariantCount {`.
pub struct VariantCountOf<T: VariantCount>(core::marker::PhantomData<T>);
impl<T: VariantCount> Get<u32> for VariantCountOf<T> {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment