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