You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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+?
Reacted by George, Sebastian Vercruysse, Mykhailo Hnap, Jeff Simpson, Aitsuki, Julian Antonielli, Zack Smith, Tiago Amorim, Caleb Reyes and d-d
Activity
joshuamegnauth54 commentedon Dec 23, 2023
I've encountered the same issue. I solved it in a hacky way by reimplementing SafeEmail.
Not ideal but also not too bad.
Zero to Production's author, Luca Palmieri, posted an excerpt that covers OP's code above if anyone wants to follow along.
npuichigo commentedon Jan 25, 2024
Same issue here @BurntSushi. How to use
quickchecktogether with other tools likefakewhich needs anRNGchoco-green commentedon Apr 30, 2024
An extension for more context if you came here from the same book - This is exactly how fake is implmenting the safeEmail function.
For more information, there is #265 to read for why rng is no longer a dependency.
Enough Digging, Enjoy coding :3
Replace QuickCheck with an own propcheck utility