Skip to content
Permalink
Browse files

Replace iterator struct with anonymous return iterator type.

  • Loading branch information
frewsxcv committed Jun 23, 2017
1 parent daed0a5 commit 917fe9241a1f0c81a73587653b48e9438487b147
Showing with 3 additions and 20 deletions.
  1. +3 −20 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
}
}

0 comments on commit 917fe92

Please sign in to comment.
You can’t perform that action at this time.