Make rand / rand_distr optional behind a default-on rand feature#104
Merged
Conversation
…88) Sandboxed targets (Typst plugins, wasm32) cannot use stateful RNG, so the random sampling stack is now optional: * rand / rand_distr become optional dependencies behind a new default-on `rand` feature; existing users see no change, and `default-features = false` drops the RNG stack entirely. * Gated behind the feature: statistics::dist, statistics::rand, util::wrapper, the rand() / rand_with_rng() / rand_with_dist() constructors, the runif! / rnorm! / dnorm! / pnorm! / rt! / dt! / pt! / rand! macros, the dist Printable impls, and the fuga / prelude re-exports of all of the above. * complex/matrix.rs imported num_traits through rand_distr's re-export; it now uses num-traits directly (new optional dep tied to the complex feature). * Examples that sample (dist, matmul, optim, clippy_verify) declare required-features = ["rand"]; rand-dependent tests and doctests are cfg-gated. * New CI job: cargo test --no-default-features plus a wasm32-unknown-unknown build, so the deterministic core (ODE, integration, splines, linear algebra) cannot silently regress. Verified locally: default 472 tests, complex 512 tests, no-default 444 tests, wasm32 build, clippy zero errors in both configurations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements #88 (issue kept open intentionally).
Sandboxed targets (Typst plugins, wasm32) cannot use stateful RNG, so this makes the random sampling stack optional:
rand/rand_distrbecome optional dependencies behind a new default-onrandfeature. Existing users see no change;default-features = falsedrops the RNG stack entirely and leaves the deterministic core (ODE solvers, numerical integration, splines, linear algebra).statistics::dist,statistics::rand,util::wrapper, therand()/rand_with_rng()/rand_with_dist()constructors, therunif!/rnorm!/dnorm!/pnorm!/rt!/dt!/pt!/rand!macros, the distPrintableimpls, and thefuga/preludere-exports of all of the above.complex/matrix.rsimportednum_traitsthroughrand_distr's re-export; it now usesnum-traitsdirectly (optional dep tied to thecomplexfeature).required-features = ["rand"]; rand-dependent tests and doctests are cfg-gated.no-rand-wasm:cargo test --no-default-featuresplus awasm32-unknown-unknownbuild, so the no-rand configuration cannot silently regress.Verified locally: default 472 tests, complex 512 tests, no-default 444 tests, wasm32 build, clippy zero errors in both configurations.