Feature-gated implementation of rand_core::RngCore
for quickcheck::Gen
#271
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale
The latest version of
quickcheck
,1.x.x
, has transformedGen
into a struct which does not implement therand_core::RngCore
trait.Reading through #241 it seems the main motivation is API stability:
rand_core
has been publishing minor releases at a much faster pace thanquickcheck
and the API does not yet seem stable enough to allowquickcheck
to cut a1.0
release without having to plan for a2.0
shortly afterwards.The other motivation mentioned in the RFC, dependency bloat, seems to have been archived due to a restructuring in
rand
's feature flagging system -rand
is in fact a dependency ofquickcheck
in1.0
.While I appreciate the driver behind the decision the outcome seems to damage interoperability across the ecosystem - with all its issues,
rand_core::RngCore
is still the reference trait for crates that want to allow a pluggable source of randomness (e.g.fake
).I believe there is path forward that allows
quickcheck
to avoid unnecessary breaking changes while enabling users that rely onrand_core
for interoperability to get aGen
struct that implementsRngCore
- the present PR.There is no denying that somebody has to pay the bill for
rand_core
's frequent breaking changes: this PR adds complexity thatquickcheck
's maintainers will have to look after going forward, therefore I understand if you don't want to merge it @BurntSushi. But I thought it was worth a shot to flesh it out as a PoC for your evaluation 😁Changes
Add an implementation of
rand_core::RngCore
forGen
behind an optional (disabled by default) feature flag -rand_core_0_6
.The features flags are structured to allow backwards-compatible additions of new
RngCore
implementations ifrand_core
were to cut a new release with breaking changes (either 0.7 or 1.x).