use super::element::Element; use super::source::Source; #[derive(Debug)] pub struct Document<'s> { pub source: &'s str, pub zeroth_section: Option>, pub children: Vec>, } #[derive(Debug)] pub struct Heading<'s> { pub source: &'s str, pub children: Vec>, } #[derive(Debug)] pub struct Section<'s> { pub source: &'s str, pub children: Vec>, } #[derive(Debug)] pub enum DocumentElement<'s> { Heading(Heading<'s>), Section(Section<'s>), } impl<'s> Source<'s> for Document<'s> { fn get_source(&'s self) -> &'s str { self.source } } impl<'s> Source<'s> for DocumentElement<'s> { fn get_source(&'s self) -> &'s str { match self { DocumentElement::Heading(obj) => obj.source, DocumentElement::Section(obj) => obj.source, } } }