Skip to content

Commit

Permalink
chore: improve ES Check type inference
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezs committed Nov 26, 2024
1 parent 277b152 commit f3eee8d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions state-chain/pallets/cf-elections/src/electoral_systems/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,18 @@ pub struct Check<ES: ElectoralSystem> {

#[macro_export]
macro_rules! single_check_new {
($arg_pre:ident, $arg_post:ident, $check_body:block, $param:ident) => {
($state_type:ty, $arg_pre:ident, $arg_post:ident, $check_body:block, $param:ident) => {
$crate::electoral_systems::mocks::SingleCheck::new(
$param,
#[track_caller]
|$arg_pre, $arg_post, $param| $check_body,
|$arg_pre: $state_type, $arg_post: $state_type, $param| $check_body,
)
};
($arg_pre:ident, $arg_post:ident, $check_body:block) => {
($state_type:ty, $arg_pre:ident, $arg_post:ident, $check_body:block) => {
$crate::electoral_systems::mocks::SingleCheck::new(
(),
#[track_caller]
|$arg_pre, $arg_post, ()| $check_body,
|$arg_pre: $state_type, $arg_post: $state_type, ()| $check_body,
)
};
}
Expand Down Expand Up @@ -347,7 +347,7 @@ macro_rules! register_checks {
impl Check<$system> {
$(
pub fn $check_name($($param: $param_type)?) -> Box<dyn $crate::electoral_systems::mocks::Checkable<$system> + 'static> {
Box::new($crate::single_check_new!($arg_1, $arg_2, $check_body $(, $param)? ))
Box::new($crate::single_check_new!(&$crate::electoral_systems::mocks::ElectoralSystemState<$system>, $arg_1, $arg_2, $check_body $(, $param)? ))
}
)*
}
Expand All @@ -365,7 +365,7 @@ macro_rules! register_checks {
{
$(
pub fn $check_name($($param: $param_type)?) -> Box<dyn $crate::electoral_systems::mocks::Checkable<ES> + 'static> {
Box::new($crate::single_check_new!($arg_1, $arg_2, $check_body $(, $param)? ))
Box::new($crate::single_check_new!(&$crate::electoral_systems::mocks::ElectoralSystemState<ES>, $arg_1, $arg_2, $check_body $(, $param)? ))
}
)+
}
Expand Down

0 comments on commit f3eee8d

Please sign in to comment.