Skip to content

Commit

Permalink
Replace iterator struct with anonymous return iterator type.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Jun 23, 2017
1 parent daed0a5 commit 917fe92
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions components/script/dom/nodelist.rs
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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
}
}

0 comments on commit 917fe92

Please sign in to comment.