mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
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:
commit
bc5e8f89ff
1 changed files with 3 additions and 20 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue