Git Product home page Git Product logo

rand's People

Contributors

alexcrichton avatar aturon avatar bors avatar brendanzab avatar brson avatar dependabot[bot] avatar dhardy avatar dsaxton avatar erickt avatar graydon avatar gridbugs avatar huonw avatar kazcw avatar nagisa avatar newpavlov avatar nikomatsakis avatar nrc avatar pcwalton avatar pitdicker avatar ralfjung avatar saona-raimundo avatar sfackler avatar sicking avatar teryror avatar theironborn avatar thestinger avatar vitiral avatar vks avatar warrenweckesser avatar zroug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rand's Issues

Missing runtime in WeightedChoice

In WeightedChoice and maybe also other algorithms, the runtime and the memory usage is missing in the documentation. These are important numbers which shouldn't be missing.

Add Cargo feature for builds without `libstd`

Allow builds without std::io, alloc and friends would help with creating libstd independent libraries that can be used with Rng which is de facto standard trait for randomness engines.

XorShiftRng duplicates itself when sampled

Since XorShiftRng implements the Rand trait, you can obtain an XorShiftRng from any Rng. Unfortunately if the original generator also happens to be an XorShiftRng you will end up with two identical generators. Example:

extern crate rand;
use rand::{SeedableRng, Rng, XorShiftRng};

fn main() {
    // (particular seed isn't important)
    let seed : [u32; 4] = [1308092148, 22089190, 2463032955, 2172661674]; 

    let mut rng1 : XorShiftRng = SeedableRng::from_seed(seed);
    let mut rng2 : XorShiftRng = rng1.gen();

    println!("rng1 -> {:?}", rng1.gen_ascii_chars().take(20).collect::<String>());
    println!("rng2 -> {:?}", rng2.gen_ascii_chars().take(20).collect::<String>());
}

results in the duplicate outputs:

rng1 -> "LJqbGKlkLfxkeYe9Ma6a"
rng2 -> "LJqbGKlkLfxkeYe9Ma6a"

This was fairly unexpected, as I was hoping (maybe foolishly) to produce an independent Rng from the first one.

Fails to compile on newest Rust 1.7.0 (2016-01-04)

Hi, it seems like rand broke my current build.

/home/travis/.cargo/registry/src/github.com-88ac128001ac3a9a/rand-0.3.12/src/isaac.rs:410:33: 410:60 note: in this expansion of ind! (defined in /home/travis/.cargo/registry/src/github.com-88ac128001ac3a9a/rand-0.3.12/src/isaac.rs)
/home/travis/.cargo/registry/src/github.com-88ac128001ac3a9a/rand-0.3.12/src/isaac.rs:419:17: 419:34 note: in this expansion of rngstepn! (defined in /home/travis/.cargo/registry/src/github.com-88ac128001ac3a9a/rand-0.3.12/src/isaac.rs)

error: aborting due to 16 previous errors
Build failed, waiting for other jobs to finish...
Could not compile `rand`.

Full log

Tests fail

The doc tests fail because extern crate rand; picks up the rand crate built-in to the compiler, not this one, meaning things like random don't exist.

Random number generators not serializable

It would be nice for the rand number generators to implement RustcEncodable and RustcDecodable.

While I am not familiar with the possible implementation difficulties, serializability of random number generators is quite useful in Python's numpy for instance --- where the Mersenne twister implementation is easily serializable given that its state is just a regular numpy array.

Call RtlGenRandom() instead of CryptGetRandom() on Windows

On Windows, os.rs can call RtlGenRandom() directly instead of jumping through hoops to obtain an HCRYPTPROV handle from CryptAcquireContextA()/CryptReleaseContext() before calling CryptGenRandom() (which just calls RtlGenRandom() itself).

Chromium, boringssl and ring, and Firefox all call RtlGenRandom() directly (which is actually exported from advapi32.dll as SystemFunction036()).

Consider switching the thread RNG to OsRng

I think we should not be encouraging ISAAC. The documentation even cautions against its use.

I know the compiler will get slow if you switch away from ISAAC, but we should just manually use ISAAC in the compiler if we really need that. Userspace CSPRNGs are bad.

Think about Isaac{,64}Rng

Currently we provide two versions of Isaac RNG, namely a 32-bit and 64-bit version. One fitting the machine word size was previously (before #14) chosen automagically by StdRng. This means currently using a matching IsaacRng version needs to use #[cfg] conditional comments in the client code.

We need to decide whether we want to remove Isaac*Rng from the rand crate or rename current IsaacRng to Isaac32Rng and add IsaacRng which selects the best implementation.

Remove dependence on libc crate

The C types (e.g. c_int) have been added to std::os::raw in Rust stable. If rand switched to using std for these types, the only use of libc left would be ENOSYS. Is the value defined by POSIX standards, or could it vary between implementations?

Cannot compile on 1.0.0-alpha.2

Seems like cannot compile on 1.0.0-alpha.2 on OS X 10.10

Here's the stacktrace

/Users/serdar/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.2.0/src/lib.rs:240:5: 240:38 error: unresolved import `std::num::wrapping::Wrapping`. Could not find `wrapping` in `std::num`
/Users/serdar/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.2.0/src/lib.rs:240 use std::num::wrapping::Wrapping as w;
                                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/serdar/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.2.0/src/chacha.rs:16:5: 16:39 error: unresolved import `core::num::wrapping::Wrapping`. Could not find `wrapping` in `core::num`
/Users/serdar/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.2.0/src/chacha.rs:16 use core::num::wrapping::Wrapping as w;
                                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/serdar/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.2.0/src/distributions/range.rs:17:5: 17:39 error: unresolved import `core::num::wrapping::Wrapping`. Could not find `wrapping` in `core::num`
/Users/serdar/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.2.0/src/distributions/range.rs:17 use core::num::wrapping::Wrapping as w;
                                                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/serdar/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.2.0/src/isaac.rs:18:5: 18:39 error: unresolved import `core::num::wrapping::Wrapping`. Could not find `wrapping` in `core::num`
/Users/serdar/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.2.0/src/isaac.rs:18 use core::num::wrapping::Wrapping as w;

Issue compiling rand

Hi,

When I tried to install serde (just put serde = "0.4.0" in my cargo.toml) I received the following errors when cargo tried to compile rand:

Command: ~ cargo build --verbose

Error report:

   Compiling rustc-serialize v0.3.14
     Running `rustc /Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/lib.rs --crate-name rustc_serialize --crate-type lib -g -C metadata=9ef26f158d5284e0 -C extra-filename=-9ef26f158d5284e0 --out-dir /Users/logan/work/rust-project/target/debug/deps --emit=dep-info,link -L dependency=/Users/logan/work/rust-project/target/debug/deps -L dependency=/Users/logan/work/rust-project/target/debug/deps -Awarnings`
   Compiling rand v0.3.8
     Running `rustc /Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/lib.rs --crate-name rand --crate-type lib -g -C metadata=b924d9fc5b3eb5b8 -C extra-filename=-b924d9fc5b3eb5b8 --out-dir /Users/logan/work/rust-project/target/debug/deps --emit=dep-info,link -L dependency=/Users/logan/work/rust-project/target/debug/deps -L dependency=/Users/logan/work/rust-project/target/debug/deps --extern libc=/Users/logan/work/rust-project/target/debug/deps/liblibc-2eda841eb12a3090.rlib -Awarnings`
       Fresh libc v0.1.8
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/lib.rs:237:5: 237:28 error: unresolved import `std::num::Wrapping`. There is no `Wrapping` in `std::num`
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/lib.rs:237 use std::num::Wrapping as w;
                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/chacha.rs:13:5: 13:28 error: unresolved import `std::num::Wrapping`. There is no `Wrapping` in `std::num`
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/chacha.rs:13 use std::num::Wrapping as w;
                                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/isaac.rs:17:5: 17:28 error: unresolved import `std::num::Wrapping`. There is no `Wrapping` in `std::num`
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/isaac.rs:17 use std::num::Wrapping as w;
                                                                                                    ^~~~~~~~~~~~~~~~~~~~~~~
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/distributions/range.rs:15:5: 15:28 error: unresolved import `std::num::Wrapping`. There is no `Wrapping` in `std::num`
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/distributions/range.rs:15 use std::num::Wrapping as w;
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 4 previous errors
Build failed, waiting for other jobs to finish...
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:435:5: 435:30 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:480:13: 480:46 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:483:9: 483:37 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:489:9: 489:41 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:492:5: 492:30 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:508:9: 508:33 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:513:9: 513:39 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:601:9: 601:43 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:605:62: 605:97 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:605:62: 605:97 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:606:58: 606:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:606:58: 606:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:607:58: 607:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:607:58: 607:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:608:58: 608:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:608:58: 608:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:609:56: 609:91 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:609:56: 609:91 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:611:62: 611:97 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:611:62: 611:97 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:612:58: 612:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:612:58: 612:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:613:58: 613:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:613:58: 613:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:614:58: 614:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:614:58: 614:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:615:56: 615:91 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:615:56: 615:91 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:620:13: 620:47 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:622:13: 622:48 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:628:9: 629:6 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:628:9: 629:6 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:663:17: 663:51 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:666:17: 666:60 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:668:17: 668:50 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:670:17: 670:62 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:673:17: 673:61 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:675:17: 675:60 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:680:17: 680:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:683:17: 683:50 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:685:17: 685:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:687:17: 687:50 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:698:13: 698:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:700:17: 700:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:736:13: 736:47 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:738:13: 738:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:745:17: 745:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:748:13: 748:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:758:13: 758:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:761:13: 761:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:766:13: 766:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:768:13: 768:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:821:13: 821:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:823:13: 823:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:830:17: 830:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:833:13: 833:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:843:13: 843:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:846:13: 846:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:857:13: 857:47 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:859:13: 859:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:866:17: 866:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:869:13: 869:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:879:13: 879:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:882:13: 882:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:896:13: 896:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:898:13: 898:44 note: expansion site
error: aborting due to 66 previous errors
Could not compile `rand`.

Caused by:
  Process didn't exit successfully: `rustc /Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/lib.rs --crate-name rand --crate-type lib -g -C metadata=b924d9fc5b3eb5b8 -C extra-filename=-b924d9fc5b3eb5b8 --out-dir /Users/logan/work/rust-project/target/debug/deps --emit=dep-info,link -L dependency=/Users/logan/work/rust-project/target/debug/deps -L dependency=/Users/logan/work/rust-project/target/debug/deps --extern libc=/Users/logan/work/rust-project/target/debug/deps/liblibc-2eda841eb12a3090.rlib -Awarnings` (exit code: 101)

rand unconditionally depends on the winapi crate

I was more than a little surprised to see this scrolling by when I built rand on a Linux box!

   Compiling winapi v0.2.1
   Compiling winapi-build v0.1.1

Is this really necessary? The only extern crate winapi I see in this crate is inside a #[cfg(windows)] module.

New crate release?

I don't see any reason not to. People (me included) have to use git:master to have access choose_mut and other small improvements.

no_std support

I think it's worth to add support for no_std. For example I am planning to implement Fortuna algorithm with no_std support (so it could be used on micro controllers) and it would be good to implement Rng trait so code implemented for it will be reused.

It can be done using std (or use-std, it seems there is currently no agreement on this) feature which will be enabled by default.

`gen_iter()` for distributions?

The Rng trait has the gen_iter() function which creates an iterator producing an infinite numbers of random numbers. It is then easy to manipulate the the iterator and generate vectors of random numbers.

Is there a reason why the various distributions do not implement this? In my particular case, I am needing to create vectors of numbers distributed normally and there is no easy way of doing that. One can't use vec![normal.ind_sample(rng); len]; because it evaluates the function once and then clones the result.

I am quite happy to implement this in this crate (if people are interested). I was thinking of maybe adding gen_iter<R: Rng>(&mut self, rng: &mut R) and gen_ind_iter<R: Rng>(&mut self, rng: &mut R) under Sample and IndependentSample respectively.

rand v0.3.7 broken on latest nightly

.../src/distributions/mod.rs:20:16: 20:21 error: unresolved import `std::num::Float`. There is no `Float` in `std::num`
.../src/distributions/mod.rs:20 use std::num::{Float, Int};

.../src/distributions/mod.rs:20:23: 20:26 error: unresolved import `std::num::Int`. There is no `Int` in `std::num`
.../src/distributions/mod.rs:20 use std::num::{Float, Int};

rustc --version
rustc 1.1.0-nightly (90cc83015 2015-04-22) (built 2015-04-23)

rand_macros isn't usefully documented

E.g. the crates.io doc link for it just goes to the main page which makes no mention. That page could get a subsection that takes about rand_macros and derive_Rand, and the crates.io doc link for rand_macros updated to point to that subsection specifically.

Bump to 0.4.0

Currently the libc is updated in the Cargo.toml but not yet published. When publishing, it is a good idea to bump the first non-zero number to avoid breaking existing code downstream.

Implement Debug for all public types

Extends/Supersedes #118

I'm creating this issue in a metabug format so that it may be used as such.

This is one major shortcoming of this crate that is relatively trivial to address. Most of these can probably just be derived.

For wrapper types (such as ReseedingRng and Generator), we should consider using specialization to add default impls for when the inner types are not Debug. Rust-lang crates are exempt from stability restrictions, correct?

RNG types

The major question to answer here is if we should reveal implementation details of these RNGs, such as seed or state variables, or just have them completely opaque.

  • ChaChaRng
  • Isaac[64]Rng
  • ReadRng
  • ReseedingRng
  • StdRng
  • ThreadRng
  • XorShiftRng

distributions module

To avoid listing all the types, I'm just going to mainly list the modules.

#120 addresses the types in these modules already, but not the loose types. Not much movement there, though.

  • exponential
  • gamma
  • normal
  • range

Loose types in this module:

  • RandSample
  • Weighted
  • WeightedChoice

Misc. Types

  • AsciiGenerator
  • Closed01
  • Generator
  • Open01

Pinging @alexcrichton as most recently active team member on this repo. Any input or anything I missed?

I may shortly start to issue PRs addressing each of these areas piecemeal (to avoid needing review of one massive PR). But mainly we should discuss the question of the implementation details on the RNGs themselves.

Is rand() dangerous?

It looks like the implementation of rand<R: Rng>(rng: &mut R) -> XorShiftRng generates a new value from rng and uses that as the seed. It seems that this could be dangerous if rng is also a XorShiftRng. Let H be the transition function. Imagine that we were to seed several XorShiftRngs using an XorShiftRng with a seed of 1. The sequence generated by the rngs will be identical except for an offset of one:

Seed: 1

1st rng: H(1), H(H(1)), H(H(H(1))), ...
2nd rng: H(H(1)), H(H(H(1))), ...
3rd rng: H(H(H(1))), H(H(H(H(1)))), ...

Broken `log` dependency with rustc nightly from 2015-02-19

A project of mine that depends on rand = "0.1" broke when I upgraded Rustc. I fixed it by manually bumping rand's dependency on log 0.2.3 to log 0.2.4 in my Cargo.lock.

Should this version bump be applied to the published rand package too? (Feel free to disregard if I've misunderstood Cargo's upgrade process!)

Rustc versions:

  • fromrustc 1.0.0-nightly (b63cee4a1 2015-02-14 17:01:11 +0000)
  • to rustc 1.0.0-nightly (522d09dfe 2015-02-19) (built 2015-02-20).

Compilation error:

$ cargo build
   Compiling libc v0.1.2
   Compiling log v0.2.3
/Users/danfox/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.2.3/src/lib.rs:570:5: 572:6 error: method `deref` has an incompatible type for trait: expected bound lifetime parameter 'a, found concrete lifetime [E0053]
/Users/danfox/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.2.3/src/lib.rs:570     fn deref(&self) -> &Box<Log> {
/Users/danfox/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.2.3/src/lib.rs:571         unsafe { mem::transmute(self.0) }
/Users/danfox/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.2.3/src/lib.rs:572     }
error: aborting due to previous error
Could not compile `log`.

`rand` uses `usize` instead of fixed size integers

The following uses should be changed to use fixed size integers instead of usize, most likely to u64:

  • many constants: MANTISSA_BITS, IGNORED_BITS
  • gen_weighted_bool
  • StdRng.{reseed,from_seed}
  • ReseedingRng::new and the corresponding *_THRESHOLD constants.

Rng should not require Sized

Currently, Rng requires Sized, which seems unnecessary. This prevents some useful patterns such as a function taking a FnMut(&mut Rng) parameter.

getrandom called on large buffers (issue adding support for openbsd's getentropy)

I'm trying to add support for OpenBSD's getentropy(2) syscall for the OS RNG as an alternative to reading from /dev/urandom. Linux's getrandom(2) is rather similar (the feature was inspired by OpenBSD's, and the manpage even includes a sample on how to emulate getentropy with getrandom) so I was originally planning on not introducing another enum value for the new random source and just reusing the getrandom interface.

The issue I'm hitting with adding getentropy support this way is that getrandom is being called on large buffers during cargo test. getentropy only supports reading 256 bytes per call, and will error with EIO on buffers larger than this.

This brings up a few questions:

  1. Is there a way to prevent reading so much of the entropy pool at a single time (other than just iterating the buffer)? Consuming excessive quantities of the entropy pool can significantly hinder performance.
  2. OpenBSD provides a cryptographically-secure userspace RNG called arc4random(3) that is currently implemented using getentropy and a ChaCha20 cipher. This is the recommended RNG for good random values in most applications. Should I reconsider using this instead of getentropy for implementing OsRng on OpenBSD? It seems slightly silly to call this though, and then pass it off to the ChaChaRng in this crate.
  3. Should I even be overloading the usage of the getrandom APIs to implement an OpenBSD-specific random source?

Can't build with latest snapshot

In the latest snapshot, I get a couple errors like this:

C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.3.0\src\os.rs:255:16: 255:16 help: add #![feature(os)] to the crate attributes to enable
C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.3.0\src\os.rs:328:62: 328:79 error: use of unstable library feature 'os': replaced with std::env APIs
C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.3.0\src\os.rs:328
        panic!("couldn't generate random bytes: {}", os::last_os_error());

                                                     ^~~~~~~~~~~~~~~~~

{Independent,}Sample trait for StandardNormal or rename to Ziggurat

All structs in rand::distributions implement the Sample and IndependentSample trait, which gives us the ability to call fn ind_sample<R: Rng>(&self, &mut R) -> Support, with Support the value of our random number.

However, StandardNormal, also in rand::distributions, does not implement the aforementioned traits, but Rand instead, which allows to call fn rand<R: Rng>(rng: &mut R) -> Self, where self will be StandardNormal(x), with x the value of our random number.

I believe this to be an inconsistency. Either StandardNormal should be moved out of rand::distributions to make it explicit that it behaves in a completely different way, or the Sample and IndependentSample traits should be implemented for it.

Alternatively, I propose StandardNormal to be renamed to ZIGNOR (or Ziggurat, I guess).

Documentation: Caching of the generator, comment is misleading in the example

Taken from the documentation https://github.com/rust-lang/rand/blob/master/src/lib.rs#L881
Is the comment in the middle correct? The second one, where we bind thread_rng() first, is faster right?

use rand::Rng;

let mut v = vec![1, 2, 3];

for x in v.iter_mut() {
    *x = rand::random()
}

// would be faster as

let mut rng = rand::thread_rng();

for x in v.iter_mut() {
    *x = rng.gen();
}

Because for me it seems like it should read would be slower than.

Consider pruning gen_weighted_bool

It's trivial to open-code; it may not be worth the benefit to have it as a method.

If it is kept, perhaps change the check from n <= 1 to n == 0 to be clearer as to the intent, as only n == 0 would cause misbehavior in gen_range().

documentation for arrays is broken

Looking at the documentation of Rand:

impl<T> Rand for [T; ($n - 1]
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ($n - 1] where T: Rand
impl<T> Rand for [T; ] where T: Rand
impl<T> Rand for [T; 32] where T: Rand

rustdoc seems to struggle with the macros used here.

error: type annotations required: cannot resolve `<f32 as core::ops::Add<_>>::Output == f32` [E0284]

With today’s rust-nightly (rust-lang/rust@6cf3b0b), rand no longer builds. It was fine in yesterday’s nightly (rust-lang/rust@d8be84e), so I’m guessing the difference is due to rust-lang/rust#23673.

$ rustc --version
rustc 1.0.0-dev (built 2015-03-31)
$ cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling libc v0.1.4
   Compiling log v0.3.1
   Compiling rand v0.3.3 (file:///home/anders/rust/rand)
src/distributions/range.rs:156:17: 156:44 error: type annotations required: cannot resolve `<f32 as core::ops::Add<_>>::Output == f32` [E0284]
src/distributions/range.rs:156                 r.low + r.range * rng.gen()
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/distributions/range.rs:145:1: 160:2 note: in expansion of float_impl!
src/distributions/range.rs:162:1: 162:20 note: expansion site
error: aborting due to previous error
Could not compile `rand`.

To learn more, run the command again with --verbose.

Implement distributions for f32

Normal and so on are only implemented for f64 at the moment.

It would simplify and beautify code that integrates with Rand greatly if they could be implemented for f32 too.

Add BorrowRng analog of BuildHasher

Anyone considered adding a BorrowRng analog of BuildHasher to simplify abstracting over random number generation methods, including situations where you must control the seed, like maybe reproducible builds or debugging probabilistic code.

pub trait BorrowRng {
    type Rng: Rng;
    fn borrow_rng(&mut self) -> &mut Self::Rng;
}

It's trivial enough to add these two lines in any trait in which you need them, but I suspect doing it as a stand alone trait in this crate could help standardize sharing a generic Rng between different probabilistic algorithms being used together.

Merging Rust Random Choice

Hi,
I want to ask, if there is an interested, to merge my small lib to this crate.
As far as I know, this random crate doesn't support to choose randomly samples by their weight/probabilities.

I have still to refactor the API and write more tests, but the implementation of the algorithm is finished. I have to implement the special case where I get a vec of Box, though.

https://github.com/StefanoD/Rust_Random_Choice

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.