diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-08-14 08:26:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-14 08:26:21 -0500 |
commit | 27d082e5779904a5e68e99841ae1511ff126bacd (patch) | |
tree | 4f849c25a1366d1af526ba24d5ddedec53301e1e /components/script/dom | |
parent | 8472699885fe81957dc9d183c209f3aa31f4c4c2 (diff) | |
parent | 9c8a810d6edf28661b6b970256b701a30822beef (diff) | |
download | servo-27d082e5779904a5e68e99841ae1511ff126bacd.tar.gz servo-27d082e5779904a5e68e99841ae1511ff126bacd.zip |
Auto merge of #12854 - nox:impl-trait, r=jdm
Use impl Trait syntax for Node::child_elements
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12854)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/node.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 2769b7503bc..34e69552f18 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -70,7 +70,7 @@ use std::borrow::ToOwned; use std::cell::{Cell, UnsafeCell}; use std::cmp::max; use std::default::Default; -use std::iter::{self, FilterMap, Peekable}; +use std::iter; use std::mem; use std::ops::Range; use string_cache::{Atom, Namespace, QualName}; @@ -781,7 +781,7 @@ impl Node { } } - pub fn child_elements(&self) -> ChildElementIterator { + pub fn child_elements(&self) -> impl Iterator<Item=Root<Element>> { self.children().filter_map(Root::downcast as fn(_) -> _).peekable() } @@ -1111,10 +1111,6 @@ impl LayoutNodeHelpers for LayoutJS<Node> { // Iteration and traversal // -pub type ChildElementIterator = - Peekable<FilterMap<NodeSiblingIterator, - fn(Root<Node>) -> Option<Root<Element>>>>; - pub struct NodeSiblingIterator { current: Option<Root<Node>>, } @@ -1460,7 +1456,7 @@ impl Node { 0 => (), // Step 6.1.2 1 => { - if !parent.child_elements().peek().is_none() { + if !parent.child_elements().next().is_none() { return Err(Error::HierarchyRequest); } if let Some(child) = child { @@ -1476,7 +1472,7 @@ impl Node { }, // Step 6.2 NodeTypeId::Element(_) => { - if !parent.child_elements().peek().is_none() { + if !parent.child_elements().next().is_none() { return Err(Error::HierarchyRequest); } if let Some(ref child) = child { @@ -1503,7 +1499,7 @@ impl Node { } }, None => { - if !parent.child_elements().peek().is_none() { + if !parent.child_elements().next().is_none() { return Err(Error::HierarchyRequest); } }, |