Open jakoschiko opened 3 years ago
That seems sensible to me. I think we should leave off the size parameter perhaps though. I regret that Gen's constructor has it instead of providing a set_size
method. So we'll want that when this new constructor is added.
Can I help by creating a PR?
Sure! I am on parental leave though, so it could be a while. I rarely get the chance to open a laptop. :)
On Mon, Feb 8, 2021, 18:50 Jakob Schikowski notifications@github.com wrote:
Can I help by creating a PR?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BurntSushi/quickcheck/issues/277#issuecomment-775542405, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADPPYSQUST7Q22MDRBGTZLS6B2DPANCNFSM4XJ6DBXQ .
I'm in no hurry, I'll do it within the next days.
May I suggest from_rng(rng)
too? @jakoschiko
I have a supplied random gen from the environment that I have to use.
I tried
Gen {
rng: SmallRng::from_rng(rng).unwrap(),
size: 42,
}
but got
183 | rng: SmallRng::from_rng(rng).unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private field
Maybe just making both fields pub
would work? Of course that depends on how settled Gen
is...
No. Because that makes rand_core
a public dependency.
@ggreif
rand_core
was recently removed from the interface, see #265. I didn't want to discuss this in this issue, I just wanted a replacement. If elegance doesn't matter, you could generate an u64
using rng
and pass it to Gen::from_seed
. I think SmallRng::from_rng
does something similar, but with more bytes.
Great, a u64
seed is perfectly adequate for my purposes. I am happy without from_rng
.
Many crates implement
quickcheck::Arbitrary
and I was very happy that I could use these implementations in dicetest by implementingquickcheck::Gen
. Unfortunately I can't do this anymore since quickcheck 1.0.Would it be possible to provide a function that creates a
Gen
from a seed? Something like that: