macro_rules! grid { () => { ... }; ( [$( $x:expr ),* ]) => { ... }; ( [$( $x0:expr ),*] $([$( $x:expr ),*])* ) => { ... }; }
Expand description
Init a grid with values.
Each array within []
represents a row starting from top to button.
Examples
In this example a grid of numbers from 1 to 9 is created:
use grid::grid;
let grid = grid![[1, 2, 3]
[4, 5, 6]
[7, 8, 9]];
assert_eq!(grid.size(), (3, 3))
Examples
Not that each row must be of the same length. The following example will not compile:
ⓘ
use grid::grid;
let grid = grid![[1, 2, 3]
[4, 5] // This does not work!
[7, 8, 9]];