Skip to content

Commit edf2893

Browse files
Rename serde1 feature to serde.
1 parent 2d5948d commit edf2893

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+135
-125
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.
1919
- Allow `UniformFloat::new` samples and `UniformFloat::sample_single` to yield `high` (#1462)
2020
- Fix portability of `rand::distributions::Slice` (#1469)
2121
- Rename `rand::distributions` to `rand::distr` (#1470)
22+
- The `serde1` feature has been renamed `serde`
2223

2324
## [0.9.0-alpha.1] - 2024-03-18
2425
- Add the `Slice::num_choices` method to the Slice distribution (#1402)

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ all-features = true
2424
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]
2525

2626
[package.metadata.playground]
27-
features = ["small_rng", "serde1"]
27+
features = ["small_rng", "serde"]
2828

2929
[features]
3030
# Meta-features:
3131
default = ["std", "std_rng", "getrandom", "small_rng"]
3232
nightly = [] # some additions requiring nightly Rust
33-
serde1 = ["serde", "rand_core/serde1"]
33+
serde = ["dep:serde", "rand_core/serde"]
3434

3535
# Option (enabled by default): without "std" rand uses libcore; this option
3636
# enables functionality expected to be available on a standard platform.
@@ -74,6 +74,6 @@ zerocopy = { version = "0.7.33", default-features = false, features = ["simd"] }
7474

7575
[dev-dependencies]
7676
rand_pcg = { path = "rand_pcg", version = "=0.9.0-alpha.1" }
77-
# Only to test serde1
77+
# Only to test serde
7878
bincode = "1.2.1"
7979
rayon = "1.7"

rand_chacha/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
- The `serde1` feature has been renamed `serde`
9+
710
## [0.9.0-alpha.1] - 2024-03-18
811

912
## [0.9.0-alpha.0] - 2024-02-18

rand_chacha/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ ppv-lite86 = { version = "0.2.14", default-features = false, features = ["simd"]
2525
serde = { version = "1.0", features = ["derive"], optional = true }
2626

2727
[dev-dependencies]
28-
# Only to test serde1
28+
# Only to test serde
2929
serde_json = "1.0"
3030
rand_core = { path = "../rand_core", version = "=0.9.0-alpha.1", features = ["getrandom"] }
3131

3232
[features]
3333
default = ["std"]
3434
getrandom = ["rand_core/getrandom"]
3535
std = ["ppv-lite86/std", "rand_core/std"]
36-
serde1 = ["serde"]
36+
serde = ["dep:serde"]

rand_chacha/src/chacha.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::guts::ChaCha;
1818
use rand_core::block::{BlockRng, BlockRngCore, CryptoBlockRng};
1919
use rand_core::{CryptoRng, RngCore, SeedableRng};
2020

21-
#[cfg(feature = "serde1")]
21+
#[cfg(feature = "serde")]
2222
use serde::{Deserialize, Deserializer, Serialize, Serializer};
2323

2424
// NB. this must remain consistent with some currently hard-coded numbers in this module
@@ -276,7 +276,7 @@ macro_rules! chacha_impl {
276276
}
277277
impl Eq for $ChaChaXRng {}
278278

279-
#[cfg(feature = "serde1")]
279+
#[cfg(feature = "serde")]
280280
impl Serialize for $ChaChaXRng {
281281
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
282282
where
@@ -285,7 +285,7 @@ macro_rules! chacha_impl {
285285
$abst::$ChaChaXRng::from(self).serialize(s)
286286
}
287287
}
288-
#[cfg(feature = "serde1")]
288+
#[cfg(feature = "serde")]
289289
impl<'de> Deserialize<'de> for $ChaChaXRng {
290290
fn deserialize<D>(d: D) -> Result<Self, D::Error>
291291
where
@@ -296,14 +296,14 @@ macro_rules! chacha_impl {
296296
}
297297

298298
mod $abst {
299-
#[cfg(feature = "serde1")]
299+
#[cfg(feature = "serde")]
300300
use serde::{Deserialize, Serialize};
301301

302302
// The abstract state of a ChaCha stream, independent of implementation choices. The
303303
// comparison and serialization of this object is considered a semver-covered part of
304304
// the API.
305305
#[derive(Debug, PartialEq, Eq)]
306-
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
306+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
307307
pub(crate) struct $ChaChaXRng {
308308
seed: [u8; 32],
309309
stream: u64,
@@ -362,12 +362,12 @@ chacha_impl!(
362362
mod test {
363363
use rand_core::{RngCore, SeedableRng};
364364

365-
#[cfg(feature = "serde1")]
365+
#[cfg(feature = "serde")]
366366
use super::{ChaCha12Rng, ChaCha20Rng, ChaCha8Rng};
367367

368368
type ChaChaRng = super::ChaCha20Rng;
369369

370-
#[cfg(feature = "serde1")]
370+
#[cfg(feature = "serde")]
371371
#[test]
372372
fn test_chacha_serde_roundtrip() {
373373
let seed = [
@@ -405,7 +405,7 @@ mod test {
405405
// However testing for equivalence of serialized data is difficult, and there shouldn't be any
406406
// reason we need to violate the stronger-than-needed condition, e.g. by changing the field
407407
// definition order.
408-
#[cfg(feature = "serde1")]
408+
#[cfg(feature = "serde")]
409409
#[test]
410410
fn test_chacha_serde_format_stability() {
411411
let j = r#"{"seed":[4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8],"stream":27182818284,"word_pos":314159265359}"#;

rand_core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
- Bump the MSRV to 1.61.0
9+
- The `serde1` feature has been renamed `serde`
910

1011
## [0.9.0-alpha.1] - 2024-03-18
1112

rand_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ all-features = true
2727
[features]
2828
std = ["alloc", "getrandom?/std"]
2929
alloc = [] # enables Vec and Box support without std
30-
serde1 = ["serde"] # enables serde for BlockRng wrapper
30+
serde = ["dep:serde"] # enables serde for BlockRng wrapper
3131

3232
[dependencies]
3333
serde = { version = "1", features = ["derive"], optional = true }

rand_core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ problems where one crate implicitly requires `rand_core` with `std` support and
6767
another crate requires `rand` *without* `std` support. However, the `rand` crate
6868
continues to enable `std` support by default, both for itself and `rand_core`.
6969

70-
The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG
70+
The `serde` feature can be used to derive `Serialize` and `Deserialize` for RNG
7171
implementations that use the `BlockRng` or `BlockRng64` wrappers.
7272

7373

rand_core/src/block.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
use crate::impls::{fill_via_u32_chunks, fill_via_u64_chunks};
5757
use crate::{CryptoRng, RngCore, SeedableRng, TryRngCore};
5858
use core::fmt;
59-
#[cfg(feature = "serde1")]
59+
#[cfg(feature = "serde")]
6060
use serde::{Deserialize, Serialize};
6161

6262
/// A trait for RNGs which do not generate random numbers individually, but in
@@ -116,9 +116,9 @@ pub trait CryptoBlockRng: BlockRngCore {}
116116
/// [`next_u64`]: RngCore::next_u64
117117
/// [`fill_bytes`]: RngCore::fill_bytes
118118
#[derive(Clone)]
119-
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
119+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
120120
#[cfg_attr(
121-
feature = "serde1",
121+
feature = "serde",
122122
serde(
123123
bound = "for<'x> R: Serialize + Deserialize<'x> + Sized, for<'x> R::Results: Serialize + Deserialize<'x>"
124124
)
@@ -283,7 +283,7 @@ impl<R: CryptoBlockRng + BlockRngCore<Item = u32>> CryptoRng for BlockRng<R> {}
283283
/// [`next_u64`]: RngCore::next_u64
284284
/// [`fill_bytes`]: RngCore::fill_bytes
285285
#[derive(Clone)]
286-
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
286+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
287287
pub struct BlockRng64<R: BlockRngCore + ?Sized> {
288288
results: R::Results,
289289
index: usize,

rand_distr/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## Unreleased
8+
- The `serde1` feature has been renamed `serde`
9+
810
### Added
911
- Add plots for `rand_distr` distributions to documentation (#1434)
1012
- Add `PertBuilder`, fix case where mode ≅ mean (#1452)

0 commit comments

Comments
 (0)