mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #8481 - frewsxcv:iterablepage-iter, r=Ms2ger
Simplify IterablePage::find <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8481) <!-- Reviewable:end -->
This commit is contained in:
commit
743ca24819
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>> {
|
||||
if self.id == id { return Some(self.clone()); }
|
||||
for page in &*self.children.borrow() {
|
||||
let found = page.find(id);
|
||||
if found.is_some() { return found; }
|
||||
if self.id == id {
|
||||
return Some(self.clone());
|
||||
}
|
||||
None
|
||||
|
||||
self.children.borrow()
|
||||
.iter()
|
||||
.filter_map(|p| p.find(id))
|
||||
.next()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue