mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Replace iterator struct with anonymous return iterator type.
This commit is contained in:
parent
daed0a5183
commit
917fe9241a
1 changed files with 3 additions and 20 deletions
|
@ -103,11 +103,9 @@ impl NodeList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter(&self) -> NodeListIterator {
|
pub fn iter<'a>(&'a self) -> impl Iterator<Item=Root<Node>> + 'a {
|
||||||
NodeListIterator {
|
let len = self.Length();
|
||||||
nodes: self,
|
(0..len).flat_map(move |i| self.Item(i))
|
||||||
offset: 0,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,18 +287,3 @@ impl ChildrenList {
|
||||||
self.last_index.set(0u32);
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue