macro_rules! nlist {
($expr:expr; _) => { ... };
($expr:expr; $len:expr) => { ... };
($($expr:expr),* $(,)?) => { ... };
}Expand description
Constructs an NList
This macro can be used in two ways:
nlist![a, b, c]: creates an NList with the listed elementsnlist![val; LEN]: creates an NList by repeating aCopyvalueLENtimes. (LENmust be either a usize expression or_)
§Example
§List each element
use nlist::{NList, Peano};
const LIST: NList<u32, Peano!(4)> = nlist::nlist![3, 5, 8, 13];
assert_eq!(LIST.into_vec(), vec![3, 5, 8, 13]);
§Repeat elements
Repeating a Copy value to construct an NList
use nlist::{NList, Peano};
// Inferring the length
let list_a: NList<u8, Peano!(2)> = nlist::nlist![5; _];
assert_eq!(list_a.into_array(), [5, 5]);
// Passing the length explicitly
let list_b: NList<&str, Peano!(3)> = nlist::nlist!["heh"; 3];
assert_eq!(list_b.into_array(), ["heh", "heh", "heh"]);