macro_rules! matrix {
    () => { ... };
    ($a:expr $(, $b: expr)*$(,)?) => { ... };
    ($($($a:expr),+$(,)?);+$(;)?) => { ... };
}
Expand description

The matrix! macro allows the declaration of a Matrix from static data. All rows must have the same number of columns. The data will be copied into the matrix. There exist two forms:

  • matrix![(row1, row2, …, rowN)], each row being an array
  • matrix![r1c1, r1c2, …, r1cN; r2c1, …,r2cN; …; rNc1, …, rNcN]
  • matrix![] creates an empty matrix with a column size of 0

Panics

This macro panics if the rows have an inconsistent number of columns.

Example

use pathfinding::matrix;

let m1 = matrix![[10, 20, 30], [40, 50, 60]];
assert_eq!(m1.columns, 3);
assert_eq!(m1.rows, 2);

let m2 = matrix![10, 20, 30; 40, 50, 60];
assert_eq!(m1, m2);