diff options
| author | Philipp A | 2018-11-24 17:08:11 +0100 |
|---|---|---|
| committer | Philipp A | 2018-11-24 17:08:11 +0100 |
| commit | 3bde67feadf75ba8a82c9d6e59580627c1c3854f (patch) | |
| tree | 1b34af9b7788ae70e031aedf78e8b87470695a1c | |
| parent | cba80480e22d8286ea468826045aa43dfa39a1ba (diff) | |
| download | rust-rst-3bde67feadf75ba8a82c9d6e59580627c1c3854f.tar.bz2 | |
streamlined macros
| -rw-r--r-- | src/document_tree/element_categories.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/document_tree/element_categories.rs b/src/document_tree/element_categories.rs index 5d0cecf..df291cf 100644 --- a/src/document_tree/element_categories.rs +++ b/src/document_tree/element_categories.rs @@ -21,13 +21,13 @@ pub trait HasChildren<C> { } macro_rules! impl_into { - ([ $( ($subentry:tt, $supcat:tt), )+ ]) => { - $( impl_into!($subentry => $supcat); )+ + ([ $( (($subcat:ident :: $entry:ident), $supcat:ident), )+ ]) => { + $( impl_into!($subcat::$entry => $supcat); )+ }; - ( ($subcat:ident :: $entry:ident) => $supcat:ident ) => { + ($subcat:ident :: $entry:ident => $supcat:ident ) => { impl Into<$supcat> for $entry { fn into(self) -> $supcat { - $supcat::$subcat($subcat::$entry(self)) + $supcat::$subcat(self.into()) } } }; @@ -36,11 +36,7 @@ macro_rules! impl_into { macro_rules! synonymous_enum { ( $subcat:ident : $($supcat:ident),+ ; $midcat:ident : $supsupcat:ident { $($entry:ident),+ $(,)* } ) => { synonymous_enum!($subcat : $( $supcat ),+ , $midcat { $($entry,)* }); - $( impl Into<$supsupcat> for $entry { - fn into(self) -> $supsupcat { - $supsupcat::$midcat($midcat::$subcat($subcat::$entry(self))) - } - } )+ + $( impl_into!($midcat::$entry => $supsupcat); )+ }; ( $subcat:ident : $($supcat:ident),+ { $($entry:ident),+ $(,)* } ) => { synonymous_enum!($subcat { $( $entry, )* }); |
