Skip to content

Commit 8d1fc5c

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 190923 b: refs/heads/auto c: 633c593 h: refs/heads/master i: 190921: 312476f 190919: 92fddf7 v: v3
1 parent bc555ac commit 8d1fc5c

File tree

26 files changed

+944
-1
lines changed

26 files changed

+944
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 5b118f5ecde796ad62fa349a045d7ad8129b711c
13+
refs/heads/auto: 633c593bc3f9787decfaf943cdc5659f132ade50
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libcollections/macros.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[cfg(stage0)]
1112
/// Creates a `Vec` containing the arguments.
1213
///
1314
/// `vec!` allows `Vec`s to be defined with the same syntax as array expressions.
@@ -45,6 +46,43 @@ macro_rules! vec {
4546
($($x:expr,)*) => (vec![$($x),*])
4647
}
4748

49+
#[cfg(not(stage0))]
50+
/// Creates a `Vec` containing the arguments.
51+
///
52+
/// `vec!` allows `Vec`s to be defined with the same syntax as array expressions.
53+
/// There are two forms of this macro:
54+
///
55+
/// - Create a `Vec` containing a given list of elements:
56+
///
57+
/// ```
58+
/// let v = vec![1, 2, 3];
59+
/// assert_eq!(v[0], 1);
60+
/// assert_eq!(v[1], 2);
61+
/// assert_eq!(v[2], 3);
62+
/// ```
63+
///
64+
/// - Create a `Vec` from a given element and size:
65+
///
66+
/// ```
67+
/// let v = vec![1; 3];
68+
/// assert_eq!(v, [1, 1, 1]);
69+
/// ```
70+
///
71+
/// Note that unlike array expressions this syntax supports all elements
72+
/// which implement `Clone` and the number of elements doesn't have to be
73+
/// a constant.
74+
#[macro_export]
75+
#[stable(feature = "rust1", since = "1.0.0")]
76+
macro_rules! vec {
77+
($elem:expr; $n:expr) => (
78+
$crate::vec::from_elem($elem, $n)
79+
);
80+
($($x:expr),*) => (
81+
<[_]>::into_vec($crate::boxed::Box::new([$($x),*]))
82+
);
83+
($($x:expr,)*) => (vec![$($x),*])
84+
}
85+
4886
/// Use the syntax described in `std::fmt` to create a value of type `String`.
4987
/// See `std::fmt` for more information.
5088
///

0 commit comments

Comments
 (0)