The use of ref actually prevents a compilation error in the following scenario.
#![deny(clippy::ref_patterns)]
fn foo(bar: &[u8]) -> u8 {
if let &[a, b, ref _rest @ .., c, d, e] = bar {
a + b + c + d + e
} else {
0
}
}
Of course, [a, b, _rest @ .., c, d, e] = bar is still possible but it is cumbersome to defer all those bytes.
#![deny(clippy::ref_patterns)]
fn foo(bar: &[u8]) -> u8 {
if let [a, b, _rest @ .., c, d, e] = bar {
*a + *b + *c + *d + *e
} else {
0
}
}
In my particular use-case I deal with +30 individual bytes, which makes things even more cumbersome.