Add size hints to early binder iterator adapters

This commit is contained in:
Michael Goulet 2022-11-22 18:35:41 +00:00
parent 66ccf36f16
commit 0ba5e7416f

View File

@ -589,6 +589,10 @@ impl<'tcx, I: IntoIterator> Iterator for SubstIter<'_, 'tcx, I>
fn next(&mut self) -> Option<Self::Item> {
Some(EarlyBinder(self.it.next()?).subst(self.tcx, self.substs))
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.it.size_hint()
}
}
impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIter<'_, 'tcx, I>
@ -631,6 +635,10 @@ impl<'tcx, I: IntoIterator> Iterator for SubstIterCopied<'_, 'tcx, I>
fn next(&mut self) -> Option<Self::Item> {
Some(EarlyBinder(*self.it.next()?).subst(self.tcx, self.substs))
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.it.size_hint()
}
}
impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIterCopied<'_, 'tcx, I>
@ -660,6 +668,10 @@ impl<T: Iterator> Iterator for EarlyBinderIter<T> {
fn next(&mut self) -> Option<Self::Item> {
self.t.next().map(|i| EarlyBinder(i))
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.t.size_hint()
}
}
impl<'tcx, T: TypeFoldable<'tcx>> ty::EarlyBinder<T> {