diff --git a/src/renderer/breadcrumb_tree.rs b/src/renderer/breadcrumb_tree.rs index 00e1804..b4bc32a 100644 --- a/src/renderer/breadcrumb_tree.rs +++ b/src/renderer/breadcrumb_tree.rs @@ -18,9 +18,13 @@ enum BreadcrumbTreeNodeElement<'a, C: IntoContextElement> { } impl<'a, C: IntoContextElement> BreadcrumbTreeNode<'a, C> { - pub fn iter(&'a self) -> IceTreeIterator<'a> { + pub fn ice_iter(&'a self) -> IceTreeIterator<'a> { IceTreeIterator(Some(self)) } + + pub fn breadcrumb_iter(&'a self) -> BreadcrumbTreeIterator<'a> { + BreadcrumbTreeIterator(Some(self)) + } } impl<'a, C: IntoContextElement> Borrow @@ -57,10 +61,22 @@ impl<'a> Iterator for IceTreeIterator<'a> { } impl<'a, C: IntoContextElement> IntoIterator for &'a BreadcrumbTreeNode<'a, C> { - type Item = &'a dyn IntoContextElement; - type IntoIter = IceTreeIterator<'a>; + type Item = &'a dyn BreadcrumbTree; + type IntoIter = BreadcrumbTreeIterator<'a>; - fn into_iter(self) -> IceTreeIterator<'a> { - self.iter() + fn into_iter(self) -> BreadcrumbTreeIterator<'a> { + self.breadcrumb_iter() + } +} + +pub struct BreadcrumbTreeIterator<'a>(Option<&'a dyn BreadcrumbTree>); + +impl<'a> Iterator for BreadcrumbTreeIterator<'a> { + type Item = &'a dyn BreadcrumbTree; + + fn next(&mut self) -> Option { + let ret = self.0; + self.0 = self.0.map(|node| node.get_parent()).flatten(); + ret } } diff --git a/src/renderer/tree_walking.rs b/src/renderer/tree_walking.rs index 574c99e..65f6cbd 100644 --- a/src/renderer/tree_walking.rs +++ b/src/renderer/tree_walking.rs @@ -24,7 +24,8 @@ fn get_first_non_pseudo_element<'a, B>( where B: IntoContextElement, { - breadcrumbs.iter().filter(|b| b.is_pseudo_element()).next() + todo!() + // breadcrumbs.iter().filter(|b| b.is_pseudo_element()).next() } pub fn walk_path<'a, B, P>(