diff options
| author | bors <bors@rust-lang.org> | 2015-01-10 14:15:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-10 14:15:09 +0000 |
| commit | c0ca57a6fb176d8082eac0ba1de4690f4c0eb0bb (patch) | |
| tree | b3a13c02de8a52c28bf07b1caae734b2a4968db6 /src/libcollections | |
| parent | a09b139f9c4c6f4a2c3fb78e906e3ae0abf7f901 (diff) | |
| parent | c163effc2b4704e3ec9d0011c90a8bd0bab4cb6c (diff) | |
Merge pull request #20771 from Kimundi/vec-macro-repeat
Enabled the `vec![]` macro to use the `[a; b]` repeat syntax. Reviewed-by: alexcrichton
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/macros.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libcollections/macros.rs b/src/libcollections/macros.rs index 0ff869d6183..c078db7d46f 100644 --- a/src/libcollections/macros.rs +++ b/src/libcollections/macros.rs @@ -1,4 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -12,6 +12,10 @@ #[macro_export] #[stable] macro_rules! vec { + ($x:expr; $y:expr) => ({ + let xs: $crate::boxed::Box<[_]> = $crate::boxed::Box::new([$x; $y]); + $crate::slice::SliceExt::into_vec(xs) + }); ($($x:expr),*) => ({ let xs: $crate::boxed::Box<[_]> = $crate::boxed::Box::new([$($x),*]); $crate::slice::SliceExt::into_vec(xs) |
