Debian Codegraph @

third_party/rust/arrayref/examples/array_refs_with_const.rs

raw
1 #[macro_use]
2 extern crate arrayref;
3
4 const SIZE: usize = 10;
5 const SIZE_A: usize = 2;
6 const SIZE_B: usize = 3;
7 const SIZE_C: usize = 5;
8
9 fn main() {
10 let x: [u8; SIZE] = [0,1,2,3,4,5,6,7,8,9];
11 let (a,b,c) = array_refs!(&x, SIZE_A, SIZE_B, SIZE_C);
12 assert_eq!(SIZE_A, a.len());
13 assert_eq!(SIZE_B, b.len());
14 assert_eq!(SIZE_C, c.len());
15 assert_eq!(*a, [0,1]);
16 assert_eq!(*b, [2,3,4]);
17 assert_eq!(*c, [5,6,7,8,9]);
18 }