arr_rs/macros/
zeros.rs

1/// Create an array of zeros
2///
3/// # Examples
4///
5/// ```
6/// use arr_rs::prelude::*;
7///
8/// let arr = array_zeros!(i32, 8);
9/// assert_eq!(array!(i32, [0, 0, 0, 0, 0, 0, 0, 0]), arr);
10/// let arr = array_zeros!(i32, 2, 2, 2);
11/// assert_eq!(array!(i32, [[[0, 0], [0, 0]], [[0, 0], [0, 0]]]), arr);
12/// ```
13#[macro_export]
14macro_rules! array_zeros {
15    (Tuple2<$t1:ty, $t2:ty>, $($tt:tt)*) => {{
16        compile_error!("only `Numeric` types are supported")
17    }};
18    (Tuple3<$t1:ty, $t2:ty, $t3:ty>, $($tt:tt)*) => {{
19        compile_error!("only `Numeric` types are supported")
20    }};
21    (List<$t1:ty>, $($tt:tt)*) => {{
22        compile_error!("only `Numeric` types are supported")
23    }};
24    (char, $($tt:tt)*) => {{
25        compile_error!("only `Numeric` types are supported")
26    }};
27    (String, $($tt:tt)*) => {{
28        compile_error!("only `Numeric` types are supported")
29    }};
30    ($([$($nested:expr),*]),* $(,)*) => {{
31        compile_error!("array_zeros! only accepts a flat list of elements");
32    }};
33    ($tt:ty, $([$($nested:expr),*]),* $(,)*) => {{
34        compile_error!("array_zeros! only accepts a flat list of elements");
35    }};
36    ($tt:ty, $($x:expr),* $(,)*) => {{
37        Array::<$tt>::zeros(vec![$($x,)*])
38    }};
39}