diff --git a/components/script/page.rs b/components/script/page.rs index 62879424927..37f4ba155bb 100644 --- a/components/script/page.rs +++ b/components/script/page.rs @@ -270,14 +270,14 @@ impl Page { impl Iterator> for PageIterator { fn next(&mut self) -> Option> { - if !self.stack.is_empty() { - let next = self.stack.pop().unwrap(); - for child in next.children.borrow().iter() { - self.stack.push(child.clone()); - } - Some(next.clone()) - } else { - None + match self.stack.pop() { + Some(next) => { + for child in next.children.borrow().iter() { + self.stack.push(child.clone()); + } + Some(next) + }, + None => None, } } }