//! returns: 0 //! An array repeat literal of unsuffixed integers takes the element type of //! its context in a return value, an argument, an assignment, a record field, //! and a nested array. /// Record with byte array fields. record Block { bytes: [u8; 4], nested: [[u8; 2]; 2], } /// Return a byte array from a repeat literal. fn bytes() -> [u8; 3] { return [200; 3]; } /// Return a wide array from a repeat literal. fn words() -> [i16; 3] { return [-5; 3]; } /// Read the last element of a byte array. fn last(a: [u8; 3]) -> u8 { return a[2]; } @default fn main() -> i32 { let b = bytes(); assert b[0] == 200; assert b[1] == 200; assert b[2] == 200; let w = words(); assert w[0] == -5; assert w[2] == -5; assert last([100; 3]) == 100; let mut m: [u8; 3] = [1; 3]; set m = [2; 3]; assert m[1] == 2; assert m[2] == 2; let wide: ?[u16; 2] = [7; 2]; if let a = wide { assert a[1] == 7; } else { panic "main: missing array"; } let block = Block { bytes: [3; 4], nested: [[9; 2]; 2] }; assert block.bytes[0] == 3; assert block.bytes[3] == 3; assert block.nested[0][1] == 9; assert block.nested[1][0] == 9; return 0; }