Skip to content

Commit

Permalink
Put where clauses to forwarding FusedIterator impls (#1027)
Browse files Browse the repository at this point in the history
add where clauses to forwarding FusedIterator impls
  • Loading branch information
Robbepop committed May 11, 2024
1 parent f3e148f commit af03289
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
28 changes: 20 additions & 8 deletions crates/collections/src/map.rs
Expand Up @@ -569,7 +569,10 @@ impl<'a, K: 'a, V: 'a> ExactSizeIterator for Iter<'a, K, V> {
}
}

impl<'a, K: 'a, V: 'a> FusedIterator for Iter<'a, K, V> {}
impl<'a, K: 'a, V: 'a> FusedIterator for Iter<'a, K, V> where
detail::IterImpl<'a, K, V>: FusedIterator
{
}

impl<'a, K: 'a, V: 'a> IntoIterator for &'a mut Map<K, V> {
type Item = (&'a K, &'a mut V);
Expand Down Expand Up @@ -608,7 +611,10 @@ impl<'a, K: 'a, V: 'a> ExactSizeIterator for IterMut<'a, K, V> {
}
}

impl<'a, K: 'a, V: 'a> FusedIterator for IterMut<'a, K, V> {}
impl<'a, K: 'a, V: 'a> FusedIterator for IterMut<'a, K, V> where
detail::IterMutImpl<'a, K, V>: FusedIterator
{
}

impl<K, V> IntoIterator for Map<K, V> {
type Item = (K, V);
Expand Down Expand Up @@ -649,7 +655,7 @@ impl<K, V> ExactSizeIterator for IntoIter<K, V> {
}
}

impl<K, V> FusedIterator for IntoIter<K, V> {}
impl<K, V> FusedIterator for IntoIter<K, V> where detail::IntoIterImpl<K, V>: FusedIterator {}

/// An iterator over the keys of a [`Map`].
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -678,7 +684,7 @@ impl<'a, K: 'a, V> ExactSizeIterator for Keys<'a, K, V> {
}
}

impl<'a, K: 'a, V> FusedIterator for Keys<'a, K, V> {}
impl<'a, K: 'a, V> FusedIterator for Keys<'a, K, V> where detail::KeysImpl<'a, K, V>: FusedIterator {}

/// An iterator over the values of a [`Map`].
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -707,7 +713,10 @@ impl<'a, K, V: 'a> ExactSizeIterator for Values<'a, K, V> {
}
}

impl<'a, K, V: 'a> FusedIterator for Values<'a, K, V> {}
impl<'a, K, V: 'a> FusedIterator for Values<'a, K, V> where
detail::ValuesImpl<'a, K, V>: FusedIterator
{
}

/// An mutable iterator over the values of a [`Map`].
#[derive(Debug)]
Expand Down Expand Up @@ -736,7 +745,10 @@ impl<'a, K, V: 'a> ExactSizeIterator for ValuesMut<'a, K, V> {
}
}

impl<'a, K, V: 'a> FusedIterator for ValuesMut<'a, K, V> {}
impl<'a, K, V: 'a> FusedIterator for ValuesMut<'a, K, V> where
detail::ValuesMutImpl<'a, K, V>: FusedIterator
{
}

/// An iterator over the owned keys of a [`Map`].
#[derive(Debug)]
Expand Down Expand Up @@ -765,7 +777,7 @@ impl<K, V> ExactSizeIterator for IntoKeys<K, V> {
}
}

impl<K, V> FusedIterator for IntoKeys<K, V> {}
impl<K, V> FusedIterator for IntoKeys<K, V> where detail::IntoKeysImpl<K, V>: FusedIterator {}

/// An iterator over the owned values of a [`Map`].
#[derive(Debug)]
Expand Down Expand Up @@ -794,4 +806,4 @@ impl<K, V> ExactSizeIterator for IntoValues<K, V> {
}
}

impl<K, V> FusedIterator for IntoValues<K, V> {}
impl<K, V> FusedIterator for IntoValues<K, V> where detail::IntoValuesImpl<K, V>: FusedIterator {}
32 changes: 26 additions & 6 deletions crates/collections/src/set.rs
Expand Up @@ -380,7 +380,7 @@ impl<'a, T: 'a> ExactSizeIterator for Iter<'a, T> {
}
}

impl<'a, T: 'a> FusedIterator for Iter<'a, T> {}
impl<'a, T: 'a> FusedIterator for Iter<'a, T> where detail::IterImpl<'a, T>: FusedIterator {}

impl<T> IntoIterator for Set<T> {
type Item = T;
Expand Down Expand Up @@ -421,7 +421,7 @@ impl<T> ExactSizeIterator for IntoIter<T> {
}
}

impl<T> FusedIterator for IntoIter<T> {}
impl<T> FusedIterator for IntoIter<T> where detail::IntoIterImpl<T>: FusedIterator {}

/// A lazy iterator producing elements in the difference of [`Set`]s.
///
Expand Down Expand Up @@ -469,7 +469,12 @@ where
}
}

impl<T> FusedIterator for Difference<'_, T> where T: Hash + Eq + Ord {}
impl<'a, T> FusedIterator for Difference<'a, T>
where
T: Hash + Eq + Ord,
detail::DifferenceImpl<'a, T>: FusedIterator,
{
}

/// A lazy iterator producing elements in the intersection of [`Set`]s.
///
Expand Down Expand Up @@ -517,7 +522,12 @@ where
}
}

impl<T> FusedIterator for Intersection<'_, T> where T: Hash + Eq + Ord {}
impl<'a, T> FusedIterator for Intersection<'a, T>
where
T: Hash + Eq + Ord,
detail::IntersectionImpl<'a, T>: FusedIterator,
{
}

/// A lazy iterator producing elements in the symmetric difference of [`Set`]s.
///
Expand Down Expand Up @@ -565,7 +575,12 @@ where
}
}

impl<T> FusedIterator for SymmetricDifference<'_, T> where T: Hash + Eq + Ord {}
impl<'a, T> FusedIterator for SymmetricDifference<'a, T>
where
T: Hash + Eq + Ord,
detail::SymmetricDifferenceImpl<'a, T>: FusedIterator,
{
}

/// A lazy iterator producing elements in the union of [`Set`]s.
///
Expand Down Expand Up @@ -613,4 +628,9 @@ where
}
}

impl<T> FusedIterator for Union<'_, T> where T: Hash + Eq + Ord {}
impl<'a, T> FusedIterator for Union<'a, T>
where
T: Hash + Eq + Ord,
detail::UnionImpl<'a, T>: FusedIterator,
{
}

0 comments on commit af03289

Please sign in to comment.