Skip to content

Commit 198caa8

Browse files
committed
Update users for the std::rand -> librand move.
1 parent 15e2898 commit 198caa8

File tree

70 files changed

+131
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+131
-64
lines changed

src/doc/guide-tasks.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ concurrency at this writing:
5050
* [`sync::DuplexStream`] - An extension of `pipes::stream` that allows both sending and receiving,
5151
* [`sync::SyncChan`] - An extension of `pipes::stream` that provides synchronous message sending,
5252
* [`sync::SyncPort`] - An extension of `pipes::stream` that acknowledges each message received,
53-
* [`sync::rendezvous`] - Creates a stream whose channel, upon sending a message, blocks until the
53+
* [`sync::rendezvous`] - Creates a stream whose channel, upon sending a message, blocks until the
5454
message is received.
5555
* [`sync::Arc`] - The Arc (atomically reference counted) type, for safely sharing immutable data,
5656
* [`sync::RWArc`] - A dual-mode Arc protected by a reader-writer lock,
5757
* [`sync::MutexArc`] - An Arc with mutable data protected by a blocking mutex,
5858
* [`sync::Semaphore`] - A counting, blocking, bounded-waiting semaphore,
59-
* [`sync::Mutex`] - A blocking, bounded-waiting, mutual exclusion lock with an associated
59+
* [`sync::Mutex`] - A blocking, bounded-waiting, mutual exclusion lock with an associated
6060
FIFO condition variable,
6161
* [`sync::RWLock`] - A blocking, no-starvation, reader-writer lock with an associated condvar,
6262
* [`sync::Barrier`] - A barrier enables multiple tasks to synchronize the beginning
@@ -343,8 +343,8 @@ a single large vector of floats. Each task needs the full vector to perform its
343343

344344
~~~
345345
# extern crate sync;
346+
extern crate rand;
346347
# use std::vec;
347-
# use std::rand;
348348
use sync::Arc;
349349
350350
fn pnorm(nums: &~[f64], p: uint) -> f64 {
@@ -376,9 +376,9 @@ created by the line
376376

377377
~~~
378378
# extern crate sync;
379+
# extern crate rand;
379380
# use sync::Arc;
380381
# use std::vec;
381-
# use std::rand;
382382
# fn main() {
383383
# let numbers = vec::from_fn(1000000, |_| rand::random::<f64>());
384384
let numbers_arc=Arc::new(numbers);
@@ -389,9 +389,9 @@ and a clone of it is sent to each task
389389

390390
~~~
391391
# extern crate sync;
392+
# extern crate rand;
392393
# use sync::Arc;
393394
# use std::vec;
394-
# use std::rand;
395395
# fn main() {
396396
# let numbers=vec::from_fn(1000000, |_| rand::random::<f64>());
397397
# let numbers_arc = Arc::new(numbers);
@@ -406,9 +406,9 @@ Each task recovers the underlying data by
406406

407407
~~~
408408
# extern crate sync;
409+
# extern crate rand;
409410
# use sync::Arc;
410411
# use std::vec;
411-
# use std::rand;
412412
# fn main() {
413413
# let numbers=vec::from_fn(1000000, |_| rand::random::<f64>());
414414
# let numbers_arc=Arc::new(numbers);

src/doc/tutorial.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ of type `ABC` can be randomly generated and converted to a string:
25292529
#[deriving(Eq)]
25302530
struct Circle { radius: f64 }
25312531
2532-
#[deriving(Rand, Show)]
2532+
#[deriving(Clone, Show)]
25332533
enum ABC { A, B, C }
25342534
~~~
25352535

src/etc/generate-deriving-span-tests.py

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
4040
#[feature(struct_variant)];
4141
extern crate extra;
42+
extern crate rand;
4243
4344
{error_deriving}
4445
struct Error;

src/libcollections/bitv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,8 @@ mod tests {
947947

948948
use std::uint;
949949
use std::vec;
950-
use std::rand;
951-
use std::rand::Rng;
950+
use rand;
951+
use rand::Rng;
952952

953953
static BENCH_BITS : uint = 1 << 14;
954954

src/libcollections/deque.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ pub mod bench {
4444
extern crate test;
4545
use self::test::BenchHarness;
4646
use std::container::MutableMap;
47-
use std::{vec, rand};
48-
use std::rand::Rng;
47+
use std::vec;
48+
use rand;
49+
use rand::Rng;
4950

5051
pub fn insert_rand_n<M:MutableMap<uint,uint>>(n: uint,
5152
map: &mut M,

src/libcollections/dlist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ mod tests {
633633
extern crate test;
634634
use self::test::BenchHarness;
635635
use deque::Deque;
636-
use std::rand;
636+
use rand;
637637
use super::{DList, Node, ListInsertion};
638638

639639
pub fn check_links<T>(list: &DList<T>) {

src/libcollections/hashmap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ use std::iter::{FilterMap, Chain, Repeat, Zip};
6161
use std::iter;
6262
use std::mem::replace;
6363
use std::num;
64-
use std::rand::Rng;
65-
use std::rand;
64+
use rand::Rng;
65+
use rand;
6666
use std::vec::{Items, MutItems};
6767
use std::vec_ng::Vec;
6868
use std::vec_ng;

src/libcollections/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#[allow(unrecognized_lint)];
2424
#[allow(default_type_param_usage)];
2525

26+
extern crate rand;
27+
2628
#[cfg(test)] extern crate test;
2729

2830
pub use bitv::Bitv;

src/libcollections/treemap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,8 @@ mod test_treemap {
10091009

10101010
use super::{TreeMap, TreeNode};
10111011

1012-
use std::rand::Rng;
1013-
use std::rand;
1012+
use rand::Rng;
1013+
use rand;
10141014

10151015
#[test]
10161016
fn find_empty() {

src/libcollections/trie.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ mod test_map {
898898
mod bench_map {
899899
extern crate test;
900900
use super::TrieMap;
901-
use std::rand::{weak_rng, Rng};
901+
use rand::{weak_rng, Rng};
902902
use self::test::BenchHarness;
903903

904904
#[bench]

src/libextra/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ Rust extras are part of the standard Rust distribution.
3434
#[deny(non_camel_case_types)];
3535
#[deny(missing_doc)];
3636

37-
extern crate sync;
38-
extern crate serialize;
3937
extern crate collections;
38+
extern crate rand;
39+
extern crate serialize;
40+
extern crate sync;
4041
extern crate time;
4142

4243
// Utility modules

src/libextra/tempfile.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
1313

1414
use std::os;
15-
use std::rand::Rng;
16-
use std::rand;
15+
use rand::Rng;
16+
use rand;
1717
use std::io;
1818
use std::io::fs;
1919

src/libflate/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ pub fn inflate_bytes_zlib(bytes: &[u8]) -> CVec<u8> {
9090

9191
#[cfg(test)]
9292
mod tests {
93+
extern crate rand;
94+
9395
use super::{inflate_bytes, deflate_bytes};
94-
use std::rand;
95-
use std::rand::Rng;
96+
use self::rand::Rng;
9697

9798
#[test]
9899
fn test_flate_round_trip() {

src/libgreen/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@
175175
#[feature(macro_rules)];
176176
#[allow(visible_private_types)];
177177

178+
extern crate rand;
179+
178180
use std::mem::replace;
179181
use std::os;
180182
use std::rt::crate_map;

src/libgreen/sched.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
use std::cast;
12-
use std::rand::{XorShiftRng, Rng, Rand};
1312
use std::rt::local::Local;
1413
use std::rt::rtio::{RemoteCallback, PausableIdleCallback, Callback, EventLoop};
1514
use std::rt::task::BlockedTask;
@@ -18,6 +17,8 @@ use std::sync::deque;
1817
use std::unstable::mutex::NativeMutex;
1918
use std::raw;
2019

20+
use rand::{XorShiftRng, Rng, Rand};
21+
2122
use TaskState;
2223
use context::Context;
2324
use coroutine::Coroutine;
@@ -957,7 +958,7 @@ fn new_sched_rng() -> XorShiftRng {
957958
fn new_sched_rng() -> XorShiftRng {
958959
use std::libc;
959960
use std::mem;
960-
use std::rand::SeedableRng;
961+
use rand::SeedableRng;
961962

962963
let fd = "/dev/urandom".with_c_str(|name| {
963964
unsafe { libc::open(name, libc::O_RDONLY, 0) }

src/libnum/bigint.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::from_str::FromStr;
2424
use std::num::CheckedDiv;
2525
use std::num::{Bitwise, ToPrimitive, FromPrimitive};
2626
use std::num::{Zero, One, ToStrRadix, FromStrRadix};
27-
use std::rand::Rng;
27+
use rand::Rng;
2828
use std::str;
2929
use std::uint;
3030
use std::vec;
@@ -1470,7 +1470,7 @@ mod biguint_tests {
14701470
use std::num::{Zero, One, FromStrRadix, ToStrRadix};
14711471
use std::num::{ToPrimitive, FromPrimitive};
14721472
use std::num::CheckedDiv;
1473-
use std::rand::{task_rng};
1473+
use rand::{task_rng};
14741474
use std::str;
14751475
use std::u64;
14761476
use std::vec;
@@ -2205,7 +2205,7 @@ mod bigint_tests {
22052205
use std::num::CheckedDiv;
22062206
use std::num::{Zero, One, FromStrRadix, ToStrRadix};
22072207
use std::num::{ToPrimitive, FromPrimitive};
2208-
use std::rand::{task_rng};
2208+
use rand::{task_rng};
22092209
use std::u64;
22102210

22112211
#[test]

src/libnum/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#[crate_type = "dylib"];
1616
#[license = "MIT/ASL2"];
1717

18+
extern crate rand;
19+
1820
pub mod bigint;
1921
pub mod rational;
2022
pub mod complex;

src/librustc/util/sha2.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,14 @@ static H256: [u32, ..8] = [
524524

525525
#[cfg(test)]
526526
mod tests {
527+
extern crate rand;
528+
527529
use super::{Digest, Sha256, FixedBuffer};
528530
use std::num::Bounded;
529531
use std::vec;
530532
use std::vec_ng::Vec;
531-
use std::rand::isaac::IsaacRng;
532-
use std::rand::Rng;
533+
use self::rand::isaac::IsaacRng;
534+
use self::rand::Rng;
533535
use serialize::hex::FromHex;
534536

535537
// A normal addition - no overflow occurs

src/libserialize/base64.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ impl<'a> FromBase64 for &'a str {
263263
#[cfg(test)]
264264
mod tests {
265265
extern crate test;
266+
extern crate rand;
266267
use self::test::BenchHarness;
267268
use base64::{Config, FromBase64, ToBase64, STANDARD, URL_SAFE};
268269

@@ -335,7 +336,7 @@ mod tests {
335336

336337
#[test]
337338
fn test_base64_random() {
338-
use std::rand::{task_rng, random, Rng};
339+
use self::rand::{task_rng, random, Rng};
339340
use std::vec;
340341

341342
for _ in range(0, 1000) {

src/libsync/arc.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,27 @@
1818
* With simple pipes, without Arc, a copy would have to be made for each task.
1919
*
2020
* ```rust
21+
* extern crate sync;
22+
* extern crate rand;
2123
* use sync::Arc;
22-
* use std::{rand, vec};
24+
* use std::vec;
2325
*
24-
* let numbers = vec::from_fn(100, |i| (i as f32) * rand::random());
25-
* let shared_numbers = Arc::new(numbers);
26+
* fn main() {
27+
* let numbers = vec::from_fn(100, |i| (i as f32) * rand::random());
28+
* let shared_numbers = Arc::new(numbers);
2629
*
27-
* for _ in range(0, 10) {
28-
* let (port, chan) = Chan::new();
29-
* chan.send(shared_numbers.clone());
30+
* for _ in range(0, 10) {
31+
* let (port, chan) = Chan::new();
32+
* chan.send(shared_numbers.clone());
3033
*
31-
* spawn(proc() {
32-
* let shared_numbers = port.recv();
33-
* let local_numbers = shared_numbers.get();
34+
* spawn(proc() {
35+
* let shared_numbers = port.recv();
36+
* let local_numbers = shared_numbers.get();
3437
*
35-
* // Work with the local numbers
36-
* });
37-
* }
38+
* // Work with the local numbers
39+
* });
40+
* }
41+
* }
3842
* ```
3943
*/
4044

src/libsyntax/ext/deriving/generic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub struct TraitDef<'a> {
216216
pub struct MethodDef<'a> {
217217
/// name of the method
218218
name: &'a str,
219-
/// List of generics, e.g. `R: std::rand::Rng`
219+
/// List of generics, e.g. `R: rand::Rng`
220220
generics: LifetimeBounds<'a>,
221221

222222
/// Whether there is a self argument (outer Option) i.e. whether

src/libuuid/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Examples of string representations:
6262
// test harness access
6363
#[cfg(test)]
6464
extern crate test;
65+
66+
extern crate rand;
6567
extern crate serialize;
6668

6769
use std::cast::{transmute,transmute_copy};
@@ -71,11 +73,11 @@ use std::fmt;
7173
use std::from_str::FromStr;
7274
use std::hash::{Hash, sip};
7375
use std::num::FromStrRadix;
74-
use std::rand::Rng;
75-
use std::rand;
7676
use std::str;
7777
use std::vec;
7878

79+
use rand::Rng;
80+
7981
use serialize::{Encoder, Encodable, Decoder, Decodable};
8082

8183
/// A 128-bit (16 byte) buffer containing the ID
@@ -519,12 +521,12 @@ impl rand::Rand for Uuid {
519521
#[cfg(test)]
520522
mod test {
521523
extern crate collections;
524+
extern crate rand;
522525

523526
use super::{Uuid, VariantMicrosoft, VariantNCS, VariantRFC4122,
524527
Version1Mac, Version2Dce, Version3Md5, Version4Random,
525528
Version5Sha1};
526529
use std::str;
527-
use std::rand;
528530
use std::io::MemWriter;
529531

530532
#[test]

src/test/bench/core-map.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
// except according to those terms.
1010

1111
extern crate collections;
12+
extern crate rand;
1213
extern crate time;
1314

1415
use collections::{TrieMap, TreeMap, HashMap, HashSet};
1516
use std::os;
16-
use std::rand::{Rng, IsaacRng, SeedableRng};
17+
use rand::{Rng, IsaacRng, SeedableRng};
1718
use std::uint;
1819
use std::vec;
1920

0 commit comments

Comments
 (0)