Skip to content

Commit 3600423

Browse files
committed
Implement IntoIterator for &[mut] Box<[T; N], A>
1 parent 4eb0c30 commit 3600423

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

library/alloc/src/boxed/iter.rs

+18
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,21 @@ impl<'a, const N: usize, I, A: Allocator> !Iterator for &'a Box<[I; N], A> {}
207207
/// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
208208
#[stable(feature = "boxed_array_value_iter", since = "CURRENT_RUSTC_VERSION")]
209209
impl<'a, const N: usize, I, A: Allocator> !Iterator for &'a mut Box<[I; N], A> {}
210+
211+
#[stable(feature = "boxed_array_value_iter", since = "CURRENT_RUSTC_VERSION")]
212+
impl<'a, T, const N: usize, A: Allocator> IntoIterator for &'a Box<[T; N], A> {
213+
type IntoIter = slice::Iter<'a, T>;
214+
type Item = &'a T;
215+
fn into_iter(self) -> slice::Iter<'a, T> {
216+
self.iter()
217+
}
218+
}
219+
220+
#[stable(feature = "boxed_array_value_iter", since = "CURRENT_RUSTC_VERSION")]
221+
impl<'a, T, const N: usize, A: Allocator> IntoIterator for &'a mut Box<[T; N], A> {
222+
type IntoIter = slice::IterMut<'a, T>;
223+
type Item = &'a mut T;
224+
fn into_iter(self) -> slice::IterMut<'a, T> {
225+
self.iter_mut()
226+
}
227+
}

0 commit comments

Comments
 (0)