]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0730.md
New upstream version 1.44.1+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0730.md
CommitLineData
60c5eb7d
XL
1An array without a fixed length was pattern-matched.
2
3Example of erroneous code:
4
5```compile_fail,E0730
6#![feature(const_generics)]
7
8fn is_123<const N: usize>(x: [u32; N]) -> bool {
9 match x {
ba9703b0
XL
10 [1, 2, ..] => true, // error: cannot pattern-match on an
11 // array without a fixed length
60c5eb7d
XL
12 _ => false
13 }
14}
15```
16
17Ensure that the pattern is consistent with the size of the matched
18array. Additional elements can be matched with `..`:
19
20```
60c5eb7d
XL
21let r = &[1, 2, 3, 4];
22match r {
23 &[a, b, ..] => { // ok!
24 println!("a={}, b={}", a, b);
25 }
26}
27```