Simplify IterablePage::find

This commit is contained in:
Corey Farwell 2015-11-12 00:03:53 -05:00
parent 1b20bc90ee
commit 94f0478f51

View file

@ -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()
}
}