mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #18494 - frewsxcv:frewsxcv-size-hint, r=jdm
Implement `size_hint` for more iterators. ``` implement size hint for more iterators because why not we like fast things ``` <!-- 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/18494) <!-- Reviewable:end -->
This commit is contained in:
commit
bb2030a493
8 changed files with 36 additions and 0 deletions
|
@ -170,6 +170,10 @@ impl Iterator for EffectiveSources {
|
|||
fn next(&mut self) -> Option<Source> {
|
||||
self.0.pop()
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
(self.0.len(), Some(self.0.len()))
|
||||
}
|
||||
}
|
||||
|
||||
struct FontFaceRuleParser<'a, 'b: 'a> {
|
||||
|
|
|
@ -99,6 +99,10 @@ impl<'a> Iterator for DeclarationImportanceIterator<'a> {
|
|||
self.iter.next().map(|(decl, important)|
|
||||
(decl, if important { Importance::Important } else { Importance::Normal }))
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
self.iter.size_hint()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DoubleEndedIterator for DeclarationImportanceIterator<'a> {
|
||||
|
|
|
@ -45,6 +45,10 @@ where
|
|||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.0.next().map(|entry| &entry.sheet)
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
self.0.size_hint()
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over the flattened view of the stylesheet collections.
|
||||
|
|
|
@ -198,6 +198,10 @@ impl<'a, 'cx, 'cx_a: 'cx, S: ToComputedValue + 'a> Iterator for ComputedVecIter<
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
(self.values.len(), Some(self.values.len()))
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait to represent the conversion between computed and specified values.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue