Make InstantiatedPredicates impl IntoIterator
This commit is contained in:
parent
91fd862df0
commit
9b28edb6d7
12 changed files with 74 additions and 65 deletions
|
@ -1252,6 +1252,33 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
|
|||
pub fn is_empty(&self) -> bool {
|
||||
self.predicates.is_empty()
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter {
|
||||
(&self).into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> IntoIterator for InstantiatedPredicates<'tcx> {
|
||||
type Item = (Predicate<'tcx>, Span);
|
||||
|
||||
type IntoIter = std::iter::Zip<std::vec::IntoIter<Predicate<'tcx>>, std::vec::IntoIter<Span>>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
std::iter::zip(self.predicates, self.spans)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> IntoIterator for &'a InstantiatedPredicates<'tcx> {
|
||||
type Item = (Predicate<'tcx>, Span);
|
||||
|
||||
type IntoIter = std::iter::Zip<
|
||||
std::iter::Copied<std::slice::Iter<'a, Predicate<'tcx>>>,
|
||||
std::iter::Copied<std::slice::Iter<'a, Span>>,
|
||||
>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
std::iter::zip(self.predicates.iter().copied(), self.spans.iter().copied())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable, Lift)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue