macro_rules! ne {
($elem:expr; $n:expr) => { ... };
($single:expr) => { ... };
($head:expr, $($tail:expr),+ $(,)?) => { ... };
}Expand description
Creates a [NonEmptyVec] containing the arguments.
This macro is very similar in goal to the standard library’s vec! macro:
- Create a [NonEmptyVec] containing a given list of elements:
let ne = ne![1, 2, 3];
assert_eq!(ne[0], 1);
assert_eq!(ne[1], 2);
assert_eq!(ne[2], 3);- Create a [NonEmptyVec] from a given element and size:
let ne = ne![1; 3];
assert_eq!(ne, NonEmptyVec::from_vec(vec![1, 1, 1]).unwrap());Note that unlike Vecs, it is not possible to create an empty [NonEmptyVec] using this macro!