1
Fork 0

simplify vec! macro

Simplify `vec!` macro by replacing 2 following branches:
- `($($x:expr),*) => (...)`
- `($($x:expr,)*) => (...)`
with one:
- `($($x:expr),* $(,)?) => (...)`
This commit is contained in:
Waffle 2020-04-09 11:03:57 +03:00
parent 11f6096a9e
commit 3ae2d21c12

View file

@ -42,10 +42,9 @@ macro_rules! vec {
($elem:expr; $n:expr) => ( ($elem:expr; $n:expr) => (
$crate::vec::from_elem($elem, $n) $crate::vec::from_elem($elem, $n)
); );
($($x:expr),*) => ( ($($x:expr),* $(,)?) => (
<[_]>::into_vec(box [$($x),*]) <[_]>::into_vec(box [$($x),*])
); );
($($x:expr,)*) => ($crate::vec![$($x),*])
} }
// HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is // HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is