mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 20:57:59 +00:00
Make parameter types implementation more flexible (#3112)
* Make parameter types implementation more flexible * Bump `impl_version`
This commit is contained in:
committed by
Gavin Wood
parent
9ee79d5c5e
commit
c42d73d302
@@ -85,19 +85,28 @@ pub use runtime_primitives::ConsensusEngineId;
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! parameter_types {
|
||||
(pub const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => (
|
||||
pub struct $name;
|
||||
$crate::parameter_types!{IMPL $name , $type , $value}
|
||||
$crate::parameter_types!{ $( $rest )* }
|
||||
);
|
||||
(const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => (
|
||||
struct $name;
|
||||
(
|
||||
$( #[ $attr:meta ] )*
|
||||
$vis:vis const $name:ident: $type:ty = $value:expr;
|
||||
$( $rest:tt )*
|
||||
) => (
|
||||
$( #[ $attr ] )*
|
||||
$vis struct $name;
|
||||
$crate::parameter_types!{IMPL $name , $type , $value}
|
||||
$crate::parameter_types!{ $( $rest )* }
|
||||
);
|
||||
() => ();
|
||||
(IMPL $name:ident , $type:ty , $value:expr) => {
|
||||
impl $crate::traits::Get<$type> for $name { fn get() -> $type { $value } }
|
||||
impl $name {
|
||||
fn get() -> $type {
|
||||
$value
|
||||
}
|
||||
}
|
||||
impl<I: From<$type>> $crate::traits::Get<I> for $name {
|
||||
fn get() -> I {
|
||||
I::from($value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user