From 154165495d0db0227d0dc45f368f6dce1123a038 Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Sat, 14 Nov 2015 23:24:56 +0100 Subject: added some convenience conversions --- src/document_tree/element_categories.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/document_tree/element_categories.rs') diff --git a/src/document_tree/element_categories.rs b/src/document_tree/element_categories.rs index d8024ad..e9d07a6 100644 --- a/src/document_tree/element_categories.rs +++ b/src/document_tree/element_categories.rs @@ -1,3 +1,5 @@ +use std::fmt::{self,Debug,Formatter}; + use super::elements::*; pub trait HasChildren { @@ -16,11 +18,16 @@ pub trait HasChildren { } macro_rules! synonymous_enum {( $name:ident { $( $entry:ident ),* } ) => ( - #[derive(Debug)] pub enum $name { - $( - $entry($entry), - )* + $( $entry($entry), )* + } + + impl Debug for $name { + fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> { + match self { + $( &$name::$entry(ref inner) => inner.fmt(fmt), )* + } + } } $( @@ -46,7 +53,7 @@ synonymous_enum!(BodyElement { synonymous_enum!(BibliographicElement { Author, Authors, Organization, Address, Contact, Version, Revision, Status, Date, Copyright, Field }); synonymous_enum!(TextOrInlineElement { - TextElement, Emphasis, Strong, Literal, Reference, FootnoteReference, CitationReference, SubstitutionReference, TitleReference, Abbreviation, Acronym, Superscript, Subscript, Inline, Problematic, Generated, Math, + String, Emphasis, Strong, Literal, Reference, FootnoteReference, CitationReference, SubstitutionReference, TitleReference, Abbreviation, Acronym, Superscript, Subscript, Inline, Problematic, Generated, Math, //also have non-inline versions. Inline image is no figure child, inline target has content TargetInline, RawInline, ImageInline }); -- cgit v1.2.3