Skip to content

Commit 77e540a

Browse files
committed
Add negative implementation of Iterator for [&[mut]] Box<[T; N], A> and [T; N]
They'll be needed for `IntoIterator` impls.
1 parent 057ed8b commit 77e540a

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

library/alloc/src/boxed/iter.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,18 @@ impl<'a> FromIterator<Cow<'a, str>> for Box<str> {
192192
String::from_iter(iter).into_boxed_str()
193193
}
194194
}
195+
196+
/// This implementation is required to make sure that the `Box<[I; N]>: IntoIterator`
197+
/// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
198+
#[stable(feature = "boxed_array_value_iter", since = "CURRENT_RUSTC_VERSION")]
199+
impl<I, const N: usize, A: Allocator> !Iterator for Box<[I; N], A> {}
200+
201+
/// This implementation is required to make sure that the `&Box<[I; N]>: IntoIterator`
202+
/// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
203+
#[stable(feature = "boxed_array_value_iter", since = "CURRENT_RUSTC_VERSION")]
204+
impl<'a, const N: usize, I, A: Allocator> !Iterator for &'a Box<[I; N], A> {}
205+
206+
/// This implementation is required to make sure that the `&mut Box<[I; N]>: IntoIterator`
207+
/// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
208+
#[stable(feature = "boxed_array_value_iter", since = "CURRENT_RUSTC_VERSION")]
209+
impl<'a, const N: usize, I, A: Allocator> !Iterator for &'a mut Box<[I; N], A> {}

library/core/src/array/iter.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ impl<T, const N: usize> IntoIter<T, N> {
3434
}
3535
}
3636

37+
#[stable(feature = "boxed_array_value_iter", since = "CURRENT_RUSTC_VERSION")]
38+
impl<T, const N: usize> !Iterator for [T; N] {}
39+
3740
// Note: the `#[rustc_skip_during_method_dispatch(array)]` on `trait IntoIterator`
3841
// hides this implementation from explicit `.into_iter()` calls on editions < 2021,
3942
// so those calls will still resolve to the slice implementation, by reference.

0 commit comments

Comments
 (0)