Skip to content

Commit 4eb0c30

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 e8de245 commit 4eb0c30

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

library/alloc/src/boxed/iter.rs

+15
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

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ pub struct IntoIter<T, const N: usize> {
3535
alive: IndexRange,
3636
}
3737

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

0 commit comments

Comments
 (0)