From 925ff6511887d917c09c61cb9d41f97ce7eab942 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 25 May 2014 01:39:37 -0700 Subject: std: Recreate a `rand` module This commit shuffles around some of the `rand` code, along with some reorganization. The new state of the world is as follows: * The librand crate now only depends on libcore. This interface is experimental. * The standard library has a new module, `std::rand`. This interface will eventually become stable. Unfortunately, this entailed more of a breaking change than just shuffling some names around. The following breaking changes were made to the rand library: * Rng::gen_vec() was removed. This has been replaced with Rng::gen_iter() which will return an infinite stream of random values. Previous behavior can be regained with `rng.gen_iter().take(n).collect()` * Rng::gen_ascii_str() was removed. This has been replaced with Rng::gen_ascii_chars() which will return an infinite stream of random ascii characters. Similarly to gen_iter(), previous behavior can be emulated with `rng.gen_ascii_chars().take(n).collect()` * {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all relied on being able to use an OSRng for seeding, but this is no longer available in librand (where these types are defined). To retain the same functionality, these types now implement the `Rand` trait so they can be generated with a random seed from another random number generator. This allows the stdlib to use an OSRng to create seeded instances of these RNGs. * Rand implementations for `Box` and `@T` were removed. These seemed to be pretty rare in the codebase, and it allows for librand to not depend on liballoc. Additionally, other pointer types like Rc and Arc were not supported. If this is undesirable, librand can depend on liballoc and regain these implementations. * The WeightedChoice structure is no longer built with a `Vec>`, but rather a `&mut [Weighted]`. This means that the WeightedChoice structure now has a lifetime associated with it. * The `sample` method on `Rng` has been moved to a top-level function in the `rand` module due to its dependence on `Vec`. cc #13851 [breaking-change] --- src/libcore/result.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/libcore/result.rs') diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 926605dddb3..fd51ede204f 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -637,11 +637,10 @@ pub fn fold_>>(iterator: Iter) -> Result<(),E> { #[cfg(test)] mod tests { use realstd::vec::Vec; - use realstd::string::String; use result::{collect, fold, fold_}; use prelude::*; - use realstd::str::{Str, StrAllocating}; + use realstd::str::Str; use iter::range; pub fn op1() -> Result { Ok(666) } -- cgit 1.4.1-3-g733a5