Switch IntoIter over to the breadcrumb iterator.
This commit is contained in:
parent
ff13d22ab6
commit
781b8f645a
@ -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<dyn IntoContextElement + 'a>
|
||||
@ -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<Self::Item> {
|
||||
let ret = self.0;
|
||||
self.0 = self.0.map(|node| node.get_parent()).flatten();
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
@ -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>(
|
||||
|
Loading…
Reference in New Issue
Block a user