Implement [value; N] syntax support for array_vec! (#118)

* Implement `[value; N]` syntax for `array_vec!`

Also implement the `($array_type:ty)` form by just calling `default()` immediately, which makes more sense.

* Add tests for `[value; N]` macro form

* Implement `[value; N]` syntax for `tiny_vec!`

Also make the same improvement to the `($array_type:ty)` macro variant that I did for `array_vec!`.

* Add tests for `[value; N]` macro form
This commit is contained in:
SlightlyOutOfPhase
2020-10-11 20:42:51 -04:00
committed by GitHub
parent bc9b76badc
commit 59a2b4c903
4 changed files with 38 additions and 2 deletions
+4 -1
View File
@@ -36,11 +36,14 @@ macro_rules! array_vec {
}
};
($array_type:ty) => {
$crate::array_vec!($array_type =>)
$crate::ArrayVec::<$array_type>::default()
};
($($elem:expr),*) => {
$crate::array_vec!(_ => $($elem),*)
};
($elem:expr; $n:expr) => {
$crate::ArrayVec::from([$elem; $n])
};
() => {
$crate::array_vec!(_)
};