auto merge of #12753 : huonw/rust/vec-macro, r=cmr
If no arguments are given to `vec!` then no pushes are emitted and so the compiler (rightly) complains that the mutability of `temp` is never used. This behaviour is rather annoying for users.
This commit is contained in:
commit
33768c46ec
1 changed files with 5 additions and 3 deletions
|
@ -366,12 +366,14 @@ macro_rules! try(
|
||||||
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
|
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/// Create a `std::vec_ng::Vec` containing the arguments.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! vec(
|
macro_rules! vec(
|
||||||
($($e:expr),*) => ({
|
($($e:expr),*) => ({
|
||||||
let mut temp = ::std::vec_ng::Vec::new();
|
// leading _ to allow empty construction without a warning.
|
||||||
$(temp.push($e);)*
|
let mut _temp = ::std::vec_ng::Vec::new();
|
||||||
temp
|
$(_temp.push($e);)*
|
||||||
|
_temp
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue