593 B
593 B
An array without a fixed length was pattern-matched.
Erroneous code example:
#![feature(const_generics)]
fn is_123<const N: usize>(x: [u32; N]) -> bool {
match x {
[1, 2, ..] => true, // error: cannot pattern-match on an
// array without a fixed length
_ => false
}
}
Ensure that the pattern is consistent with the size of the matched array.
Additional elements can be matched with ..:
let r = &[1, 2, 3, 4];
match r {
&[a, b, ..] => { // ok!
println!("a={}, b={}", a, b);
}
}