array

Macro array 

Source
macro_rules! array {
    ($([$([$([$([$([$($x:expr),* $(,)?]),+ $(,)?]),+ $(,)?]),+ $(,)?]),+ $(,)?]),+ $(,)?) => { ... };
    ($([$([$([$([$($x:expr),* $(,)?]),+ $(,)?]),+ $(,)?]),+ $(,)?]),+ $(,)?) => { ... };
    ($([$([$([$($x:expr),* $(,)?]),+ $(,)?]),+ $(,)?]),+ $(,)?) => { ... };
    ($([$([$($x:expr),* $(,)?]),+ $(,)?]),+ $(,)?) => { ... };
    ($([$($x:expr),* $(,)?]),+ $(,)?) => { ... };
    ($($x:expr),* $(,)?) => { ... };
    ([[[[[$elem:expr; $i:expr]; $j:expr]; $k:expr]; $l:expr]; $m:expr]; $n:expr) => { ... };
    ([[[[$elem:expr; $i:expr]; $j:expr]; $k:expr]; $l:expr]; $m:expr) => { ... };
    ([[[$elem:expr; $i:expr]; $j:expr]; $k:expr]; $l:expr) => { ... };
    ([[$elem:expr; $i:expr]; $j:expr]; $k:expr) => { ... };
    ([$elem:expr; $i:expr]; $j:expr) => { ... };
    ($elem:expr; $i:expr) => { ... };
}
Expand description

Creates an inline multidimensional array containing the arguments.

This macro is used to create an array, similar to the vec! macro for vectors. There are two forms of this macro:

  • Create an array containing a given list of elements:
use mdarray::{Array, array};

let a = array![[1, 2, 3], [4, 5, 6]];

assert_eq!(a, Array::from([[1, 2, 3], [4, 5, 6]]));
  • Create an array from a given element and shape:
use mdarray::{array, Const, Array};

let a = array![[1; 3]; 2];

assert_eq!(a, Array::from([[1; 3]; 2]));

In the second form, the argument must be an array repeat expression with constant shape.