Skip to content

Instantly share code, notes, and snippets.

@urbanautomaton
Created June 19, 2019 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urbanautomaton/874ce67d4c602b71bdb1c6d55f9a4e17 to your computer and use it in GitHub Desktop.
Save urbanautomaton/874ce67d4c602b71bdb1c6d55f9a4e17 to your computer and use it in GitHub Desktop.
[package]
name = "rand_experiment"
version = "0.1.0"
authors = ["Simon Coffey <simon.coffey@futurelearn.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.6.5"
rand_xoshiro = "0.3.0"
use rand::Rng;
use rand_xoshiro::rand_core::*;
use rand_xoshiro::Xoshiro256StarStar;
fn wat<R: Rng>(rng: &mut R) -> f64 {
rng.gen()
}
fn main() {
let mut rng = Xoshiro256StarStar::seed_from_u64(0);
for i in 0..100 {
let x: f64 = wat(&mut rng);
println!("Random: {}", x);
}
}
Compiling rand_experiment v0.1.0 (/Users/simon/dev/personal/computation_club/rand_experiment)
error[E0277]: the trait bound `rand_xoshiro::xoshiro256starstar::Xoshiro256StarStar: rand_core::RngCore` is not satisfied
--> src/main.rs:13:22
|
13 | let x: f64 = wat(&mut rng);
| ^^^ the trait `rand_core::RngCore` is not implemented for `rand_xoshiro::xoshiro256starstar::Xoshiro256StarStar`
|
= note: required because of the requirements on the impl of `rand::Rng` for `rand_xoshiro::xoshiro256starstar::Xoshiro256StarStar`
note: required by `wat`
--> src/main.rs:5:1
|
5 | fn wat<R: Rng>(rng: &mut R) -> f64 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: Could not compile `rand_experiment`.
To learn more, run the command again with --verbose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment