Skip to content

Commit 8d7ad35

Browse files
committed
---
yaml --- r: 57707 b: refs/heads/incoming c: d0451ee h: refs/heads/master i: 57705: 3942c45 57703: bdb1d32 v: v3
1 parent 92d82b0 commit 8d7ad35

File tree

14 files changed

+105
-330
lines changed

14 files changed

+105
-330
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: bf67eb2362b7d0f37012f2d6dac604c3bbacd2c6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: edc1324e7e665080e6695625ba6a5ede3e32f5a8
9+
refs/heads/incoming: d0451eebc41d4eaddcc299c868b5ad983e8c8eb9
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/gc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pub mod rustrt {
7373
pub unsafe fn rust_gc_metadata() -> *Word;
7474

7575
pub unsafe fn rust_get_stack_segment() -> *StackSegment;
76+
pub unsafe fn rust_get_c_stack() -> *StackSegment;
7677
}
7778
}
7879

branches/incoming/src/libcore/rand.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,40 @@ impl Rand for bool {
115115
}
116116
}
117117

118+
macro_rules! tuple_impl {
119+
// use variables to indicate the arity of the tuple
120+
($($tyvar:ident),* ) => {
121+
// the trailing commas are for the 1 tuple
122+
impl<
123+
$( $tyvar : Rand ),*
124+
> Rand for ( $( $tyvar ),* , ) {
125+
126+
fn rand (_rng: @Rng) -> ( $( $tyvar ),* , ) {
127+
(
128+
// use the $var's to get the appropriate number of repeats
129+
// (they're not actually needed)
130+
$(
131+
_rng.gen::<$tyvar>()
132+
),*
133+
,
134+
)
135+
}
136+
}
137+
}
138+
}
139+
140+
impl Rand for () { fn rand(_: @Rng) -> () { () } }
141+
tuple_impl!{A}
142+
tuple_impl!{A, B}
143+
tuple_impl!{A, B, C}
144+
tuple_impl!{A, B, C, D}
145+
tuple_impl!{A, B, C, D, E}
146+
tuple_impl!{A, B, C, D, E, F}
147+
tuple_impl!{A, B, C, D, E, F, G}
148+
tuple_impl!{A, B, C, D, E, F, G, H}
149+
tuple_impl!{A, B, C, D, E, F, G, H, I}
150+
tuple_impl!{A, B, C, D, E, F, G, H, I, J}
151+
118152
impl<T:Rand> Rand for Option<T> {
119153
fn rand(rng: @rand::Rng) -> Option<T> {
120154
if rng.gen_bool() {
@@ -125,6 +159,14 @@ impl<T:Rand> Rand for Option<T> {
125159
}
126160
}
127161

162+
impl<T: Rand> Rand for ~T {
163+
fn rand(rng: @Rng) -> ~T { ~rng.gen() }
164+
}
165+
166+
impl<T: Rand> Rand for @T {
167+
fn rand(rng: @Rng) -> @T { @rng.gen() }
168+
}
169+
128170
#[allow(non_camel_case_types)] // runtime type
129171
pub enum rust_rng {}
130172

@@ -927,6 +969,10 @@ mod tests {
927969
let _n : uint = rand::random();
928970
let _f : f32 = rand::random();
929971
let _o : Option<Option<i8>> = rand::random();
972+
let _many : ((),
973+
(~uint, @int, ~Option<~(@char, ~(@bool,))>),
974+
(u8, i8, u16, i16, u32, i32, u64, i64),
975+
(f32, (f64, (float,)))) = rand::random();
930976
}
931977
}
932978

0 commit comments

Comments
 (0)