Following the zero2production book With quickcheck = "0.9.2", quickcheck_macros = "0.9.1" and fake = "~2.3", the following works, because the function Arbitrary::arbitrary expected a Gen trait, and Gen used to be a trait:
#[derive(Debug, Clone)]
struct ValidEmailFixture(pub String);
impl quickcheck::Arbitrary for ValidEmailFixture {
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
let email = SafeEmail().fake_with_rng(g);
Self(email)
}
}
#[quickcheck_macros::quickcheck]
fn valid_emails_are_parsed_successfully(valid_email: ValidEmailFixture) -> bool {
SubscriberEmail::parse(valid_email.0).is_ok()
}
Then we pass the mutable reference g into SafeEmail().fake_with_rng(g); and it works - fake generates random valid emails.
However, in quickcheck = "1", quickcheck::Gen is no trait anymore, only a struct. I haven't found out how to access the inner rng: rand::rngs::SmallRng of Gen to pass it into SafeEmail().fake_with_rng and get fake to work with quickcheck.
How is it still possible in 1+?
Following the zero2production book With
quickcheck = "0.9.2",quickcheck_macros = "0.9.1"andfake = "~2.3", the following works, because the functionArbitrary::arbitraryexpected aGentrait, andGenused to be a trait:Then we pass the mutable reference
gintoSafeEmail().fake_with_rng(g);and it works -fakegenerates random valid emails.However, in
quickcheck = "1",quickcheck::Genis no trait anymore, only a struct. I haven't found out how to access the innerrng: rand::rngs::SmallRngofGento pass it intoSafeEmail().fake_with_rngand getfaketo work withquickcheck.How is it still possible in 1+?