Skip to content

Commit

Permalink
Rollup merge of #70949 - WaffleLapkin:simlify_vec_macro, r=petrochenkov
Browse files Browse the repository at this point in the history
simplify `vec!` macro

Simplify `vec!` macro by replacing 2 following branches:
- `($($x:expr),*) => (...)`
- `($($x:expr,)*) => (...)`
with one:
- `($($x:expr),* $(,)?) => (...)`

This is a minor change, however, this will make the documentation cleaner
  • Loading branch information
Dylan-DPC committed Apr 14, 2020
2 parents b5dc6e6 + 2c23bd4 commit e2f2423
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/liballoc/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ macro_rules! vec {
($elem:expr; $n:expr) => (
$crate::vec::from_elem($elem, $n)
);
($($x:expr),*) => (
<[_]>::into_vec(box [$($x),*])
($($x:expr),+ $(,)?) => (
<[_]>::into_vec(box [$($x),+])
);
($($x:expr,)*) => ($crate::vec![$($x),*])
}

// HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is
Expand Down

0 comments on commit e2f2423

Please sign in to comment.