Implement get_additional_properties for Document.
This commit is contained in:
parent
42dcd41e48
commit
d965dd6fd1
@ -93,8 +93,7 @@ impl<'s> Heading<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_additional_properties(&self) -> impl Iterator<Item = &NodeProperty<'s>> {
|
pub fn get_additional_properties(&self) -> impl Iterator<Item = &NodeProperty<'s>> {
|
||||||
let foo = self
|
self.children
|
||||||
.children
|
|
||||||
.iter()
|
.iter()
|
||||||
.take(1)
|
.take(1)
|
||||||
.filter_map(|c| match c {
|
.filter_map(|c| match c {
|
||||||
@ -107,7 +106,28 @@ impl<'s> Heading<'s> {
|
|||||||
Element::PropertyDrawer(property_drawer) => Some(property_drawer),
|
Element::PropertyDrawer(property_drawer) => Some(property_drawer),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.flat_map(|property_drawer| property_drawer.children.iter());
|
.flat_map(|property_drawer| property_drawer.children.iter())
|
||||||
foo
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'s> Document<'s> {
|
||||||
|
pub fn get_additional_properties(&self) -> impl Iterator<Item = &NodeProperty<'s>> {
|
||||||
|
let zeroth_section_children = self
|
||||||
|
.zeroth_section
|
||||||
|
.iter()
|
||||||
|
.flat_map(|zeroth_section| zeroth_section.children.iter());
|
||||||
|
let property_drawer = zeroth_section_children
|
||||||
|
.take_while(|element| match element {
|
||||||
|
Element::Comment(_) => true,
|
||||||
|
Element::PropertyDrawer(_) => true,
|
||||||
|
_ => false,
|
||||||
|
})
|
||||||
|
.find_map(|element| match element {
|
||||||
|
Element::PropertyDrawer(property_drawer) => Some(property_drawer),
|
||||||
|
_ => None,
|
||||||
|
});
|
||||||
|
property_drawer
|
||||||
|
.into_iter()
|
||||||
|
.flat_map(|property_drawer| property_drawer.children.iter())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user