Skip to content

Commit ca2eb4a

Browse files
authored
the Item of a Windows iterator should be an explicitly sized array : iter.rs
the Windows iterator normally returns an array of type [T], but this results in an error where the compiler can't determine the size of the array at compile time when you try to use the [T] in another function like: Vec_of_i32.windows(2).all(|x| x.do_something()); doesn't compile because x is of type: [i32] and the compiler doesn't know the size. x's type should be: [i32;2] and the compiler now knows x's size and the code now compiles correctly
1 parent caa8172 commit ca2eb4a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/slice/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,10 +1347,10 @@ impl<T> Clone for Windows<'_, T> {
13471347

13481348
#[stable(feature = "rust1", since = "1.0.0")]
13491349
impl<'a, T> Iterator for Windows<'a, T> {
1350-
type Item = &'a [T];
1350+
type Item = &'a [T;self.size.get()];
13511351

13521352
#[inline]
1353-
fn next(&mut self) -> Option<&'a [T]> {
1353+
fn next(&mut self) -> Option<&'a [T;self.size.get()]> {
13541354
if self.size.get() > self.v.len() {
13551355
None
13561356
} else {

0 commit comments

Comments
 (0)