Move IsSubType and write some docs for the trait (#7350)

* Move `IsSubType` and write some docs for the trait

This moves the `IsSubType` trait from dispatch.rs to traits.rs. It also
adds docs to make the trait better understandable.

* Update frame/support/src/traits.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Bastian Köcher
2020-10-19 10:24:13 +02:00
committed by GitHub
parent 74e8691aa8
commit 87c18598fc
7 changed files with 58 additions and 16 deletions
+1 -5
View File
@@ -1900,10 +1900,6 @@ macro_rules! decl_module {
}
}
pub trait IsSubType<T> {
fn is_sub_type(&self) -> Option<&T>;
}
/// Implement a meta-dispatch module to dispatch to other dispatchers.
#[macro_export]
macro_rules! impl_outer_dispatch {
@@ -2001,7 +1997,7 @@ macro_rules! impl_outer_dispatch {
}
$(
impl $crate::dispatch::IsSubType<$crate::dispatch::CallableCallFor<$camelcase, $runtime>> for $call_type {
impl $crate::traits::IsSubType<$crate::dispatch::CallableCallFor<$camelcase, $runtime>> for $call_type {
#[allow(unreachable_patterns)]
fn is_sub_type(&self) -> Option<&$crate::dispatch::CallableCallFor<$camelcase, $runtime>> {
match *self {