Clippy::pattern_type_mismatch when destructuring Windows<T>

Hello, I'm having trouble figuring out how to write a pattern to destructure Windows.

Clippy complains about both of the following patterns,

#![warn(clippy::pattern_type_mismatch)]
struct Thing;
fn main() {
    let list = vec![Thing, Thing];
    let mut iter = list.windows(2);
    while let Some([_a, _b]) = iter.next() { } // pattern_type_mismatch
    while let Some(&[ref _a, ref _b]) = iter.next() { } // needless_borrowed_reference
}

What pattern should I be using and do you know of any good articles that might make me more confident in addressing pattern_type_mismatch warnings?

Thanks!

2 Likes

Sigh, I was getting suspicious that there wasn't a resolution without quelling one warning or the other. Oh well. Thanks for the link!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.