mirror of
https://github.com/openharmony/third_party_rust_tinyvec.git
synced 2026-07-21 01:35:22 -04:00
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:
committed by
GitHub
parent
bc9b76badc
commit
59a2b4c903
+4
-1
@@ -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!(_)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user