Skip to content

Commit dec163e

Browse files
committed
---
yaml --- r: 24173 b: refs/heads/master c: 18bce94 h: refs/heads/master i: 24171: b189372 v: v3
1 parent 72ceeef commit dec163e

File tree

5 files changed

+60
-92
lines changed

5 files changed

+60
-92
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4f15b0d97528d57d3dd8b4fa8dc27fad41a9ebf6
2+
refs/heads/master: 18bce94a5ad4f08c6263a72993d749d82b336663
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/dvec.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ Note that recursive use is not permitted.
1616
use cast::reinterpret_cast;
1717
use ptr::null;
1818

19-
export DVec;
20-
export from_elem;
21-
export from_vec;
22-
export extensions;
23-
export unwrap;
24-
2519
/**
2620
* A growable, modifiable vector type that accumulates elements into a
2721
* unique vector.
@@ -57,27 +51,27 @@ type DVec_<A> = {
5751
mut data: ~[A]
5852
};
5953

60-
enum DVec<A> {
54+
pub enum DVec<A> {
6155
DVec_(DVec_<A>)
6256
}
6357

6458
/// Creates a new, empty dvec
65-
fn DVec<A>() -> DVec<A> {
59+
pub fn DVec<A>() -> DVec<A> {
6660
DVec_({mut data: ~[]})
6761
}
6862

6963
/// Creates a new dvec with a single element
70-
fn from_elem<A>(+e: A) -> DVec<A> {
64+
pub fn from_elem<A>(+e: A) -> DVec<A> {
7165
DVec_({mut data: ~[move e]})
7266
}
7367

7468
/// Creates a new dvec with the contents of a vector
75-
fn from_vec<A>(+v: ~[A]) -> DVec<A> {
69+
pub fn from_vec<A>(+v: ~[A]) -> DVec<A> {
7670
DVec_({mut data: move v})
7771
}
7872

7973
/// Consumes the vector and returns its contents
80-
fn unwrap<A>(+d: DVec<A>) -> ~[A] {
74+
pub fn unwrap<A>(+d: DVec<A>) -> ~[A] {
8175
let DVec_({data: v}) <- d;
8276
move v
8377
}

trunk/src/libcore/rand.rs

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
//! Random number generation
22
3-
export Rng, seed, seeded_rng, Weighted, extensions;
4-
export xorshift, seeded_xorshift;
5-
63
#[allow(non_camel_case_types)] // runtime type
74
enum rctx {}
85

@@ -17,13 +14,13 @@ extern mod rustrt {
1714
}
1815

1916
/// A random number generator
20-
trait Rng {
17+
pub trait Rng {
2118
/// Return the next random integer
2219
fn next() -> u32;
2320
}
2421

2522
/// A value with a particular weight compared to other values
26-
type Weighted<T> = { weight: uint, item: T };
23+
pub type Weighted<T> = { weight: uint, item: T };
2724

2825
/// Extension methods for random number generators
2926
impl Rng {
@@ -260,12 +257,12 @@ impl @RandRes: Rng {
260257
}
261258

262259
/// Create a new random seed for seeded_rng
263-
fn seed() -> ~[u8] {
260+
pub fn seed() -> ~[u8] {
264261
rustrt::rand_seed()
265262
}
266263

267264
/// Create a random number generator with a system specified seed
268-
fn Rng() -> Rng {
265+
pub fn Rng() -> Rng {
269266
@RandRes(rustrt::rand_new()) as Rng
270267
}
271268

@@ -275,7 +272,7 @@ fn Rng() -> Rng {
275272
* all other generators constructed with the same seed. The seed may be any
276273
* length.
277274
*/
278-
fn seeded_rng(seed: ~[u8]) -> Rng {
275+
pub fn seeded_rng(seed: ~[u8]) -> Rng {
279276
@RandRes(rustrt::rand_new_seeded(seed)) as Rng
280277
}
281278

@@ -299,29 +296,27 @@ impl XorShiftState: Rng {
299296
}
300297
}
301298

302-
fn xorshift() -> Rng {
299+
pub fn xorshift() -> Rng {
303300
// constants taken from http://en.wikipedia.org/wiki/Xorshift
304301
seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32)
305302
}
306303

307-
fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng {
304+
pub fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng {
308305
{mut x: x, mut y: y, mut z: z, mut w: w} as Rng
309306
}
310307

311308
#[cfg(test)]
312-
mod tests {
313-
#[legacy_exports];
314-
309+
pub mod tests {
315310
#[test]
316-
fn rng_seeded() {
311+
pub fn rng_seeded() {
317312
let seed = rand::seed();
318313
let ra = rand::seeded_rng(seed);
319314
let rb = rand::seeded_rng(seed);
320315
assert ra.gen_str(100u) == rb.gen_str(100u);
321316
}
322317

323318
#[test]
324-
fn rng_seeded_custom_seed() {
319+
pub fn rng_seeded_custom_seed() {
325320
// much shorter than generated seeds which are 1024 bytes
326321
let seed = ~[2u8, 32u8, 4u8, 32u8, 51u8];
327322
let ra = rand::seeded_rng(seed);
@@ -330,7 +325,7 @@ mod tests {
330325
}
331326

332327
#[test]
333-
fn rng_seeded_custom_seed2() {
328+
pub fn rng_seeded_custom_seed2() {
334329
let seed = ~[2u8, 32u8, 4u8, 32u8, 51u8];
335330
let ra = rand::seeded_rng(seed);
336331
// Regression test that isaac is actually using the above vector
@@ -341,7 +336,7 @@ mod tests {
341336
}
342337

343338
#[test]
344-
fn gen_int_range() {
339+
pub fn gen_int_range() {
345340
let r = rand::Rng();
346341
let a = r.gen_int_range(-3, 42);
347342
assert a >= -3 && a < 42;
@@ -352,12 +347,12 @@ mod tests {
352347
#[test]
353348
#[should_fail]
354349
#[ignore(cfg(windows))]
355-
fn gen_int_from_fail() {
350+
pub fn gen_int_from_fail() {
356351
rand::Rng().gen_int_range(5, -2);
357352
}
358353

359354
#[test]
360-
fn gen_uint_range() {
355+
pub fn gen_uint_range() {
361356
let r = rand::Rng();
362357
let a = r.gen_uint_range(3u, 42u);
363358
assert a >= 3u && a < 42u;
@@ -368,27 +363,27 @@ mod tests {
368363
#[test]
369364
#[should_fail]
370365
#[ignore(cfg(windows))]
371-
fn gen_uint_range_fail() {
366+
pub fn gen_uint_range_fail() {
372367
rand::Rng().gen_uint_range(5u, 2u);
373368
}
374369

375370
#[test]
376-
fn gen_float() {
371+
pub fn gen_float() {
377372
let r = rand::Rng();
378373
let a = r.gen_float();
379374
let b = r.gen_float();
380375
log(debug, (a, b));
381376
}
382377

383378
#[test]
384-
fn gen_weighted_bool() {
379+
pub fn gen_weighted_bool() {
385380
let r = rand::Rng();
386381
assert r.gen_weighted_bool(0u) == true;
387382
assert r.gen_weighted_bool(1u) == true;
388383
}
389384

390385
#[test]
391-
fn gen_str() {
386+
pub fn gen_str() {
392387
let r = rand::Rng();
393388
log(debug, r.gen_str(10u));
394389
log(debug, r.gen_str(10u));
@@ -399,29 +394,29 @@ mod tests {
399394
}
400395

401396
#[test]
402-
fn gen_bytes() {
397+
pub fn gen_bytes() {
403398
let r = rand::Rng();
404399
assert r.gen_bytes(0u).len() == 0u;
405400
assert r.gen_bytes(10u).len() == 10u;
406401
assert r.gen_bytes(16u).len() == 16u;
407402
}
408403

409404
#[test]
410-
fn choose() {
405+
pub fn choose() {
411406
let r = rand::Rng();
412407
assert r.choose([1, 1, 1]) == 1;
413408
}
414409

415410
#[test]
416-
fn choose_option() {
411+
pub fn choose_option() {
417412
let r = rand::Rng();
418413
let x: Option<int> = r.choose_option([]);
419414
assert x.is_none();
420415
assert r.choose_option([1, 1, 1]) == Some(1);
421416
}
422417

423418
#[test]
424-
fn choose_weighted() {
419+
pub fn choose_weighted() {
425420
let r = rand::Rng();
426421
assert r.choose_weighted(~[{weight: 1u, item: 42}]) == 42;
427422
assert r.choose_weighted(~[
@@ -431,7 +426,7 @@ mod tests {
431426
}
432427

433428
#[test]
434-
fn choose_weighted_option() {
429+
pub fn choose_weighted_option() {
435430
let r = rand::Rng();
436431
assert r.choose_weighted_option(~[{weight: 1u, item: 42}]) ==
437432
Some(42);
@@ -444,7 +439,7 @@ mod tests {
444439
}
445440

446441
#[test]
447-
fn weighted_vec() {
442+
pub fn weighted_vec() {
448443
let r = rand::Rng();
449444
let empty: ~[int] = ~[];
450445
assert r.weighted_vec(~[]) == empty;
@@ -456,7 +451,7 @@ mod tests {
456451
}
457452

458453
#[test]
459-
fn shuffle() {
454+
pub fn shuffle() {
460455
let r = rand::Rng();
461456
let empty: ~[int] = ~[];
462457
assert r.shuffle(~[]) == empty;

trunk/src/libcore/run.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ use option::{Some, None};
77
use libc::{pid_t, c_void, c_int};
88
use io::ReaderUtil;
99

10-
export Program;
11-
export run_program;
12-
export start_program;
13-
export program_output;
14-
export spawn_process;
15-
export waitpid;
16-
1710
#[abi = "cdecl"]
1811
extern mod rustrt {
1912
#[legacy_exports];
@@ -24,7 +17,7 @@ extern mod rustrt {
2417
}
2518

2619
/// A value representing a child process
27-
trait Program {
20+
pub trait Program {
2821
/// Returns the process id of the program
2922
fn get_id() -> pid_t;
3023

@@ -68,7 +61,7 @@ trait Program {
6861
*
6962
* The process id of the spawned process
7063
*/
71-
fn spawn_process(prog: &str, args: &[~str],
64+
pub fn spawn_process(prog: &str, args: &[~str],
7265
env: &Option<~[(~str,~str)]>,
7366
dir: &Option<~str>,
7467
in_fd: c_int, out_fd: c_int, err_fd: c_int)
@@ -166,7 +159,7 @@ fn with_dirp<T>(d: &Option<~str>,
166159
*
167160
* The process id
168161
*/
169-
fn run_program(prog: &str, args: &[~str]) -> int {
162+
pub fn run_program(prog: &str, args: &[~str]) -> int {
170163
let pid = spawn_process(prog, args, &None, &None,
171164
0i32, 0i32, 0i32);
172165
if pid == -1 as pid_t { fail; }
@@ -189,7 +182,7 @@ fn run_program(prog: &str, args: &[~str]) -> int {
189182
*
190183
* A class with a <program> field
191184
*/
192-
fn start_program(prog: &str, args: &[~str]) -> Program {
185+
pub fn start_program(prog: &str, args: &[~str]) -> Program {
193186
let pipe_input = os::pipe();
194187
let pipe_output = os::pipe();
195188
let pipe_err = os::pipe();
@@ -278,7 +271,7 @@ fn read_all(rd: io::Reader) -> ~str {
278271
* A record, {status: int, out: str, err: str} containing the exit code,
279272
* the contents of stdout and the contents of stderr.
280273
*/
281-
fn program_output(prog: &str, args: &[~str]) ->
274+
pub fn program_output(prog: &str, args: &[~str]) ->
282275
{status: int, out: ~str, err: ~str} {
283276

284277
let pipe_in = os::pipe();
@@ -359,7 +352,7 @@ fn readclose(fd: c_int) -> ~str {
359352
}
360353

361354
/// Waits for a process to exit and returns the exit code
362-
fn waitpid(pid: pid_t) -> int {
355+
pub fn waitpid(pid: pid_t) -> int {
363356
return waitpid_os(pid);
364357

365358
#[cfg(windows)]
@@ -402,20 +395,18 @@ fn waitpid(pid: pid_t) -> int {
402395

403396
#[cfg(test)]
404397
mod tests {
405-
#[legacy_exports];
406-
407398
use io::WriterUtil;
408399

409400
// Regression test for memory leaks
410401
#[ignore(cfg(windows))] // FIXME (#2626)
411-
fn test_leaks() {
402+
pub fn test_leaks() {
412403
run::run_program("echo", []);
413404
run::start_program("echo", []);
414405
run::program_output("echo", []);
415406
}
416407

417408
#[test]
418-
fn test_pipes() {
409+
pub fn test_pipes() {
419410
let pipe_in = os::pipe();
420411
let pipe_out = os::pipe();
421412
let pipe_err = os::pipe();
@@ -441,7 +432,7 @@ mod tests {
441432
}
442433

443434
#[test]
444-
fn waitpid() {
435+
pub fn waitpid() {
445436
let pid = run::spawn_process("false", [],
446437
&None, &None,
447438
0i32, 0i32, 0i32);

0 commit comments

Comments
 (0)