Auto merge of #17488 - frewsxcv:frewsxcv-return-node-list, r=jdm

Replace iterator struct with anonymous return iterator type.

```
hi servo. it's been
some time. here's a pull request.
i hope you like it.
```

<!-- 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/17488)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-23 12:38:02 -07:00 committed by GitHub
commit bc5e8f89ff

View file

@ -103,11 +103,9 @@ impl NodeList {
}
}
pub fn iter(&self) -> NodeListIterator {
NodeListIterator {
nodes: self,
offset: 0,
}
pub fn iter<'a>(&'a self) -> impl Iterator<Item=Root<Node>> + 'a {
let len = self.Length();
(0..len).flat_map(move |i| self.Item(i))
}
}
@ -289,18 +287,3 @@ impl ChildrenList {
self.last_index.set(0u32);
}
}
pub struct NodeListIterator<'a> {
nodes: &'a NodeList,
offset: u32,
}
impl<'a> Iterator for NodeListIterator<'a> {
type Item = Root<Node>;
fn next(&mut self) -> Option<Root<Node>> {
let result = self.nodes.Item(self.offset);
self.offset = self.offset + 1;
result
}
}