Macro view

Source
macro_rules! view {
    ($([$([$([$([$([$($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 a multidimensional array view containing the arguments.

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

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

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

assert_eq!(a, DView::<_, 2>::from(&[[1, 2, 3], [4, 5, 6]]));
  • Create an array view from a given element and shape:
use mdarray::{view, DView};

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

assert_eq!(a, DView::<_, 2>::from(&[[1; 3]; 2]));

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