Skip to content

Commit

Permalink
Use explicit features rather than implicit.
Browse files Browse the repository at this point in the history
In Rust 2024 edition, implicit features from optional dependencies
are going away and explicit features are required.

This changes all features using optional dependencies to use the
"dep:" syntax to avoid creating implicit features.

It also adds new explicit features for optional dependencies that
didn't previously have an explicit feature to enable them.

This does mean that some previously publicly visible features are
now gone, like `serde`. These features would not have worked
previously as the code is guarded by, for example, checks for
`feature = "serde1"`, so just enabling the optional dependency
wouldn't have been sufficient to enable the code.
  • Loading branch information
waywardmonkeys committed Jul 20, 2024
1 parent 1e381d1 commit d4a825d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ features = ["small_rng", "serde1"]
# Meta-features:
default = ["std", "std_rng", "getrandom", "small_rng"]
nightly = [] # some additions requiring nightly Rust
serde1 = ["serde", "rand_core/serde1"]
serde1 = ["dep:serde", "rand_core/serde1"]

# Option (enabled by default): without "std" rand uses libcore; this option
# enables functionality expected to be available on a standard platform.
Expand All @@ -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
2 changes: 1 addition & 1 deletion rand_chacha/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ rand_core = { path = "../rand_core", version = "=0.9.0-alpha.1", features = ["ge
default = ["std"]
getrandom = ["rand_core/getrandom"]
std = ["ppv-lite86/std", "rand_core/std"]
serde1 = ["serde"]
serde1 = ["dep:serde"]
3 changes: 2 additions & 1 deletion rand_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ all-features = true
[features]
std = ["alloc", "getrandom?/std"]
alloc = [] # enables Vec and Box support without std
serde1 = ["serde"] # enables serde for BlockRng wrapper
getrandom = ["dep:getrandom"]
serde1 = ["dep:serde"] # enables serde for BlockRng wrapper

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

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

[dependencies]
rand = { path = "..", version = "=0.9.0-alpha.1", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion rand_pcg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ all-features = true
rustdoc-args = ["--generate-link-to-definition"]

[features]
serde1 = ["serde"]
serde1 = ["dep:serde"]
getrandom = ["rand_core/getrandom"]

[dependencies]
Expand Down

0 comments on commit d4a825d

Please sign in to comment.