diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-06-23 12:38:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-23 12:38:02 -0700 |
commit | bc5e8f89fff9bf1922638b3eb2f4c75148dcad1e (patch) | |
tree | f2f98517572a812f3f16fba1fc05a9536c9cd353 | |
parent | 7e493529f0eca00b92274a047f843b990e6bd1a9 (diff) | |
parent | 917fe9241a1f0c81a73587653b48e9438487b147 (diff) | |
download | servo-bc5e8f89fff9bf1922638b3eb2f4c75148dcad1e.tar.gz servo-bc5e8f89fff9bf1922638b3eb2f4c75148dcad1e.zip |
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 -->
-rw-r--r-- | components/script/dom/nodelist.rs | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index 39b4cc1c41e..31e4dfb40c8 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -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 - } -} |