Skip to content

Instantly share code, notes, and snippets.

@russelldb
Last active July 5, 2019 11:39
Show Gist options
  • Save russelldb/49b96ca2e23dfab8a0f03090144735e4 to your computer and use it in GitHub Desktop.
Save russelldb/49b96ca2e23dfab8a0f03090144735e4 to your computer and use it in GitHub Desktop.
[package]
name = "ex1"
version = "0.1.0"
authors = ["Russell Brown <russell.brown@joyent.com>"]
edition = "2018"
[dependencies]
[dev-dependencies]
quickcheck = "0.8.5"
rand = "0.7.0"
#[derive(Debug, PartialEq, Clone)]
struct Point {
x: u32,
y: u32,
}
fn main() {
let p = Point { x: 12, y: 13 };
println!("point is {:?}", p);
}
#[cfg(test)]
mod tests {
use super::*;
use quickcheck::{quickcheck, Arbitrary, Gen};
use rand::Rng;
impl Arbitrary for Point {
fn arbitrary<G: Gen>(g: &mut G) -> Point {
let x = g.gen::<u32>();
let y = g.gen::<u32>();
Point { x, y }
}
}
quickcheck! {
fn prop(p: Point) -> bool {
p == p
}
}
}
12:38:48:ex1(mre *) $ cargo test --verbose
Fresh spin v0.5.0
Fresh autocfg v0.1.4
Fresh rand_core v0.4.0
Fresh ucd-util v0.1.3
Fresh utf8-ranges v1.0.3
Fresh ppv-lite86 v0.2.5
Fresh cfg-if v0.1.9
Fresh lazy_static v1.3.0
Fresh regex-syntax v0.6.7
Fresh rand_core v0.3.1
Fresh rand_jitter v0.1.4
Fresh log v0.4.6
Fresh memchr v2.2.0
Fresh libc v0.2.58
Fresh thread_local v0.3.6
Fresh c2-chacha v0.2.2
Fresh aho-corasick v0.7.4
Fresh getrandom v0.1.6
Fresh rand_hc v0.1.0
Fresh rand_os v0.1.3
Fresh rand_chacha v0.1.1
Fresh rand_xorshift v0.1.1
Fresh rand_pcg v0.1.2
Fresh rand_isaac v0.1.1
Fresh regex v1.1.8
Fresh rand_core v0.5.0
Fresh env_logger v0.6.2
Fresh rand_chacha v0.2.0
Fresh rand v0.6.5
Fresh rand v0.7.0
Fresh quickcheck v0.8.5
Compiling ex1 v0.1.0 (/home/russell/dev/rust/talent-plan-1/bb2/ex1)
Running `rustc --edition=2018 --crate-name ex1 src/main.rs --color always --emit=dep-info,link -C debuginfo=2 --test -C metadata=a7f0c5284470e309 -C extra-filename=-a7f0c5284470e309 --out-dir /home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/deps -C incremental=/home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/incremental -L dependency=/home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/deps --extern quickcheck=/home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/deps/libquickcheck-714f2be38d602717.rlib --extern rand=/home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/deps/librand-261f8b5c0796a35b.rlib`
error[E0599]: no method named `gen` found for type `&mut G` in the current scope
--> src/main.rs:20:23
|
20 | let x = g.gen::<u32>();
| ^^^
|
= note: the method `gen` exists but the following trait bounds were not satisfied:
`&mut G : rand::Rng`
`G : rand::Rng`
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
`use rand::Rng;`
error[E0599]: no method named `gen` found for type `&mut G` in the current scope
--> src/main.rs:21:23
|
21 | let y = g.gen::<u32>();
| ^^^
|
= note: the method `gen` exists but the following trait bounds were not satisfied:
`&mut G : rand::Rng`
`G : rand::Rng`
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
`use rand::Rng;`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0599`.
error: Could not compile `ex1`.
Caused by:
process didn't exit successfully: `rustc --edition=2018 --crate-name ex1 src/main.rs --color always --emit=dep-info,link -C debuginfo=2 --test -C metadata=a7f0c5284470e309 -C extra-filename=-a7f0c5284470e309 --out-dir /home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/deps -C incremental=/home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/incremental -L dependency=/home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/deps --extern quickcheck=/home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/deps/libquickcheck-714f2be38d602717.rlib --extern rand=/home/russell/dev/rust/talent-plan-1/bb2/ex1/target/debug/deps/librand-261f8b5c0796a35b.rlib` (exit code: 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment