diff --git a/traits/src/lib.rs b/traits/src/lib.rs index d8dfbab39..2aa3e19c9 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -1,7 +1,8 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; -use sp_runtime::RuntimeDebug; +use impl_trait_for_tuples::impl_for_tuples; +use sp_runtime::{DispatchResult, RuntimeDebug}; use sp_std::{ cmp::{Eq, PartialEq}, prelude::Vec, @@ -64,11 +65,23 @@ pub struct TimestampedValue { pub timestamp: Moment, } -#[impl_trait_for_tuples::impl_for_tuples(30)] +#[impl_for_tuples(30)] pub trait Happened { fn happened(t: &T); } +pub trait Handler { + fn handle(t: &T) -> DispatchResult; +} + +#[impl_for_tuples(30)] +impl Handler for Tuple { + fn handle(t: &T) -> DispatchResult { + for_tuples!( #( Tuple::handle(t); )* ); + Ok(()) + } +} + pub trait Contains { fn contains(t: &T) -> bool; }