-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
To fix:
|
This is based off of pitdicker's small-rngs crate and O'Neill's pcg-cpp lib.
See rust-lang/cargo#5364 regarding the latter issue. We can work around with Regarding the first item, upgrading the minimum Rust version, I'd really appreciate some feedback. We could use a build-script to auto-enable |
@dhardy you can use |
See Cargo issue 5364
Thanks @Nemo157. Any idea how I can enable dependency features from a build script? The following allows the RNG using if version().unwrap() >= Version::parse("1.26.0").unwrap() {
println!("cargo:rustc-cfg=rust_1_26"); ... but using this plus the So apparently auto-detection of the compiler version cannot support Serde for both old compilers and newer ones. |
Unfortunately this does not support serde1 on old compilers, since build scripts do not appear to be able to specify feature requirements of dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it seems like the implementations are faithful to their C counterparts and are proven such via the tests. Beyond that I had some comments as a fairly new person to the rand
package and random number generation algorithms in general.
rand_pcg/src/pcg64.rs
Outdated
/// Congruential Generator, and 32-bit output via "xorshift high (bits), | ||
/// random rotation" output function. | ||
/// | ||
/// This is equivalent to `pcg_engines::setseq_xsh_rr_64_32`, also known as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be a good idea to link to that here? At very least saying what repo that came from might be a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you think we should link to? It seems to be loosely documented in the C and C++ sources.
rand_pcg/src/pcg128.rs
Outdated
/// Congruential Generator, and 64-bit output via "xorshift low (bits), | ||
/// random rotation" output function. | ||
/// | ||
/// This is equivalent to `pcg_engines::mcg_xsl_rr_128_64`. Note that we |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be a good idea to link to that here? At very least saying what repo that came from might be a good idea.
Thanks for the review @coltfred! |
As far as I'm aware not possible, if you want conditional |
I tried, but it seems build scripts can't enable features either. I think in this case it's better just to say Serde support requires a compiler >= 1.26 rather than add an explicit feature for users to enable. |
Yeah, I meant a feature that users of the crate would have to enable if they want the support (I haven't looked into what you're actually using the feature for, there's definitely a large space of conditional compilation around feature unions—especially with optional dependencies—that isn't supported well be Cargo at the moment). |
Note that until rand_core 0.2 and 0.3 are compatible or rand 0.5 uses rand_core 0.3, you need to force rand_core to 0.2 to run these.
Benchmarks (including
|
rust-random/rand#619 should fix the failing test (when I figure it out). |
This requires use of the rand_core 0.2.2 shim
This is based off of pitdicker's small-rngs crate and O'Neill's pcg-cpp lib.
I took some liberty to come up with new names for these RNGs.
One small niggle: the initialisation of the MCG variant forces one or two bits high, depending on the source. I copied the C version here.
@vks review?
@imneme for your information, the plan is to publish this as the
rand_pcg
Rust crate