Boxing made it work.
This commit is contained in:
parent
0073af19e2
commit
793e560bd5
@ -14,24 +14,22 @@ pub enum Token<'r, 's> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'r, 's> Token<'r, 's> {
|
impl<'r, 's> Token<'r, 's> {
|
||||||
pub fn iter_tokens(&self) -> impl Iterator<Item = Token<'r, 's>> {
|
pub fn iter_tokens(&self) -> Box<dyn Iterator<Item = Token<'r, 's>> + '_> {
|
||||||
match self {
|
match self {
|
||||||
Token::Document(document) => document
|
Token::Document(document) => Box::new(
|
||||||
.zeroth_section
|
document
|
||||||
.iter()
|
.zeroth_section
|
||||||
.map(Token::Section)
|
|
||||||
.chain(document.children.iter().map(Token::Heading)),
|
|
||||||
Token::Heading(heading) => {
|
|
||||||
heading
|
|
||||||
.title
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(Token::Object)
|
.map(Token::Section)
|
||||||
.chain(heading.children.iter().map(|de| match de {
|
.chain(document.children.iter().map(Token::Heading)),
|
||||||
DocumentElement::Heading(ref obj) => Token::Heading(obj),
|
),
|
||||||
DocumentElement::Section(ref obj) => Token::Section(obj),
|
Token::Heading(heading) => Box::new(heading.title.iter().map(Token::Object).chain(
|
||||||
}))
|
heading.children.iter().map(|de| match de {
|
||||||
}
|
DocumentElement::Heading(ref obj) => Token::Heading(obj),
|
||||||
Token::Section(section) => section.children.iter().map(Token::Element),
|
DocumentElement::Section(ref obj) => Token::Section(obj),
|
||||||
|
}),
|
||||||
|
)),
|
||||||
|
Token::Section(section) => Box::new(section.children.iter().map(Token::Element)),
|
||||||
Token::Object(_) => panic!(),
|
Token::Object(_) => panic!(),
|
||||||
Token::Element(_) => panic!(),
|
Token::Element(_) => panic!(),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user