mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Simplify IterablePage::find
This commit is contained in:
parent
1b20bc90ee
commit
94f0478f51
1 changed files with 7 additions and 5 deletions
|
@ -43,12 +43,14 @@ impl IterablePage for Rc<Page> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn find(&self, id: PipelineId) -> Option<Rc<Page>> {
|
fn find(&self, id: PipelineId) -> Option<Rc<Page>> {
|
||||||
if self.id == id { return Some(self.clone()); }
|
if self.id == id {
|
||||||
for page in &*self.children.borrow() {
|
return Some(self.clone());
|
||||||
let found = page.find(id);
|
|
||||||
if found.is_some() { return found; }
|
|
||||||
}
|
}
|
||||||
None
|
|
||||||
|
self.children.borrow()
|
||||||
|
.iter()
|
||||||
|
.filter_map(|p| p.find(id))
|
||||||
|
.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue