Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use explicit features rather than implicit. #1473

Merged
merged 6 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.
- Fix portability of `rand::distributions::Slice` (#1469)
- Rename `rand::distributions` to `rand::distr` (#1470)
- The `serde1` feature has been renamed `serde` (#1477)
- The implicit feature `rand_chacha` has been removed. This is enabled by `std_rng`. (#1473)
- Mark `WeightError`, `PoissonError`, `BinomialError` as `#[non_exhaustive]` (#1480).
- Add `UniformUsize` and use to make `Uniform` for `usize` portable (#1487)
- Remove support for generating `isize` and `usize` values with `Standard`, `Uniform` and `Fill` and usage as a `WeightedAliasIndex` weight (#1487)
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ getrandom = ["rand_core/getrandom"]
simd_support = ["zerocopy/simd-nightly"]

# Option (enabled by default): enable StdRng
std_rng = ["rand_chacha"]
std_rng = ["dep:rand_chacha"]

# Option: enable SmallRng
small_rng = []
Expand All @@ -56,6 +56,9 @@ small_rng = []
# Note: enabling this option is expected to affect reproducibility of results.
unbiased = []

# Option: enable logging
log = ["dep:log"]

[workspace]
members = [
"rand_core",
Expand Down
1 change: 1 addition & 0 deletions rand_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ all-features = true
[features]
std = ["alloc", "getrandom?/std"]
alloc = [] # enables Vec and Box support without std
getrandom = ["dep:getrandom"]
serde = ["dep:serde"] # enables serde for BlockRng wrapper

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rand_distr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ alloc = ["rand/alloc"]
# feature (default-enabled) will have the same effect.
std_math = ["num-traits/std"]

serde = ["dep:serde", "rand/serde"]
serde = ["dep:serde", "dep:serde_with", "rand/serde"]

[dependencies]
rand = { path = "..", version = "=0.9.0-alpha.1", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions rand_distr/src/dirichlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ use crate::{Beta, Distribution, Exp1, Gamma, Open01, StandardNormal};
use core::fmt;
use num_traits::{Float, NumCast};
use rand::Rng;
#[cfg(feature = "serde_with")]
#[cfg(feature = "serde")]
use serde_with::serde_as;

use alloc::{boxed::Box, vec, vec::Vec};

#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde_with", serde_as)]
#[cfg_attr(feature = "serde", serde_as)]
struct DirichletFromGamma<F, const N: usize>
where
F: Float,
Expand Down Expand Up @@ -171,7 +171,7 @@ where
}

#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde_with", serde_as)]
#[cfg_attr(feature = "serde", serde_as)]
enum DirichletRepr<F, const N: usize>
where
F: Float,
Expand Down Expand Up @@ -214,7 +214,7 @@ where
/// let samples = dirichlet.sample(&mut rand::rng());
/// println!("{:?} is from a Dirichlet([1.0, 2.0, 3.0]) distribution", samples);
/// ```
#[cfg_attr(feature = "serde_with", serde_as)]
#[cfg_attr(feature = "serde", serde_as)]
#[derive(Clone, Debug, PartialEq)]
pub struct Dirichlet<F, const N: usize>
where
Expand Down
Loading