Skip to content

Commit

Permalink
Rename serde-1 to serde1
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Apr 4, 2018
1 parent 204b9e4 commit ec6f5dd
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 41 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ matrix:
install:
script:
- cargo test --all --tests --no-default-features
- cargo test --features serde-1,log
- cargo test --features serde1,log
- rust: stable
os: osx
install:
script:
- cargo test --all --tests --no-default-features
- cargo test --features serde-1,log
- cargo test --features serde1,log
- rust: beta
install:
script:
- cargo test --all --tests --no-default-features
- cargo test --tests --no-default-features --features=serde-1
- cargo test --tests --no-default-features --features=serde1
- rust: nightly
install:
before_script:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
script:
- cargo test --all --tests --no-default-features --features=alloc
- cargo test --all --features=alloc
- cargo test --features serde-1,log,nightly
- cargo test --features serde1,log,nightly
- cargo test --benches
- cargo doc --no-deps --all --all-features
- cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You may also find the [Update Guide](UPDATING.md) useful.
- Create a seperate `rand_core` crate. (#288)
- Deprecate `rand_derive`. (#256)
- Add `log` feature. Logging is now available in `JitterRng`, `OsRng`, `EntropyRng` and `ReseedingRng`. (#246)
- Add `serde-1` feature for some PRNGs. (#189)
- Add `serde1` feature for some PRNGs. (#189)
- `stdweb` feature for `OsRng` support on WASM via stdweb. (#272, #336)

### `Rng` trait
Expand Down Expand Up @@ -55,7 +55,7 @@ You may also find the [Update Guide](UPDATING.md) useful.
- Change `thread_rng` reseeding threshold to 32 MiB. (#277)
- PRNGs no longer implement `Copy`. (#209)
- `Debug` implementations no longer show internals. (#209)
- Implement serialisation for `XorShiftRng`, `IsaacRng` and `Isaac64Rng` under the `serde-1` feature. (#189)
- Implement serialization for `XorShiftRng`, `IsaacRng` and `Isaac64Rng` under the `serde1` feature. (#189)
- Implement `BlockRngCore` for `ChaChaCore` and `Hc128Core`. (#281)
- All PRNGs are now portable across big- and little-endian architectures. (#209)
- `Isaac64Rng::next_u32` no longer throws away half the results. (#209)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nightly = ["i128_support"] # enables all features requiring nightly rust
std = ["rand_core/std", "alloc", "libc", "winapi", "cloudabi", "fuchsia-zircon"]
alloc = ["rand_core/alloc"] # enables Vec and Box support (without std)
i128_support = [] # enables i128 and u128 support
serde-1 = ["serde", "serde_derive", "rand_core/serde-1"] # enables serialization for PRNGs
serde1 = ["serde", "serde_derive", "rand_core/serde1"] # enables serialization for PRNGs

[workspace]
members = ["rand_core"]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ optional features are available:
- `i128_support` enables support for generating `u128` and `i128` values
- `log` enables some logging via the `log` crate
- `nightly` enables all unstable features (`i128_support`)
- `serde-1` enables serialisation for some types, via Serde version 1
- `serde1` enables serialization for some types, via Serde version 1
- `stdweb` enables support for `OsRng` on WASM via stdweb.
- `std` enabled by default; by setting "default-features = false" `no_std`
mode is activated; this removes features depending on `std` functionality:
Expand Down Expand Up @@ -132,7 +132,7 @@ cargo test --tests --no-default-features
cargo test --tests --no-default-features --features alloc
# Test log and serde support
cargo test --features serde-1,log
cargo test --features serde1,log
# Test 128-bit support (requires nightly)
cargo test --all --features nightly
Expand Down
2 changes: 1 addition & 1 deletion UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ deprecation of `Rand`.
Several new Cargo feature flags have been added:

- `alloc`, used without `std`, allows use of `Box` and `Vec`
- `serde-1` adds serialisation support to some PRNGs
- `serde1` adds serialization support to some PRNGs
- `log` adds logging in a few places (primarily to `OsRng` and `JitterRng`)

### `Rng` and friends (core traits)
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ build: false
test_script:
- cargo test --benches
- cargo test --all
- cargo test --features serde-1,log,nightly
- cargo test --features serde1,log,nightly
- cargo test --all --tests --no-default-features --features=alloc
- cargo test --tests --no-default-features --features=serde-1
- cargo test --tests --no-default-features --features=serde1
2 changes: 1 addition & 1 deletion rand_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ appveyor = { repository = "alexcrichton/rand" }
# default = ["std"]
std = ["alloc"] # use std library; should be default but for above bug
alloc = [] # enables Vec and Box support without std
serde-1 = ["serde", "serde_derive"] # enables serde for BlockRng wrapper
serde1 = ["serde", "serde_derive"] # enables serde for BlockRng wrapper

[dependencies]
serde = { version = "1", optional = true }
Expand Down
10 changes: 5 additions & 5 deletions rand_core/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use core::cmp::min;
use core::mem::size_of;
use {RngCore, BlockRngCore, CryptoRng, SeedableRng, Error};

#[cfg(feature="serde-1")] use serde::{Serialize, Deserialize};
#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};

/// Implement `next_u64` via `next_u32`, little-endian order.
pub fn next_u64_via_u32<R: RngCore + ?Sized>(rng: &mut R) -> u64 {
Expand Down Expand Up @@ -186,9 +186,9 @@ pub fn next_u64_via_fill<R: RngCore + ?Sized>(rng: &mut R) -> u64 {
/// [`RngCore`]: ../RngCore.t.html
/// [`SeedableRng`]: ../SeedableRng.t.html
#[derive(Clone)]
#[cfg_attr(feature="serde-1", derive(Serialize, Deserialize))]
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
pub struct BlockRng<R: BlockRngCore + ?Sized> {
#[cfg_attr(feature="serde-1", serde(bound(
#[cfg_attr(feature="serde1", serde(bound(
serialize = "R::Results: Serialize",
deserialize = "R::Results: Deserialize<'de>")))]
results: R::Results,
Expand Down Expand Up @@ -372,9 +372,9 @@ impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng<R> {
/// [`RngCore`]: ../RngCore.t.html
/// [`BlockRng`]: struct.BlockRng.html
#[derive(Clone)]
#[cfg_attr(feature="serde-1", derive(Serialize, Deserialize))]
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
pub struct BlockRng64<R: BlockRngCore + ?Sized> {
#[cfg_attr(feature="serde-1", serde(bound(
#[cfg_attr(feature="serde1", serde(bound(
serialize = "R::Results: Serialize",
deserialize = "R::Results: Deserialize<'de>")))]
results: R::Results,
Expand Down
4 changes: 2 additions & 2 deletions rand_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@

#[cfg(feature="std")] extern crate core;
#[cfg(all(feature = "alloc", not(feature="std")))] extern crate alloc;
#[cfg(feature="serde-1")] extern crate serde;
#[cfg(feature="serde-1")] #[macro_use] extern crate serde_derive;
#[cfg(feature="serde1")] extern crate serde;
#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive;


use core::default::Default;
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@
#[cfg(feature="std")] extern crate std as core;
#[cfg(all(feature = "alloc", not(feature="std")))] extern crate alloc;

#[cfg(test)] #[cfg(feature="serde-1")] extern crate bincode;
#[cfg(feature="serde-1")] extern crate serde;
#[cfg(feature="serde-1")] #[macro_use] extern crate serde_derive;
#[cfg(test)] #[cfg(feature="serde1")] extern crate bincode;
#[cfg(feature="serde1")] extern crate serde;
#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive;

#[cfg(all(target_arch = "wasm32", feature = "stdweb"))]
#[macro_use]
Expand Down
8 changes: 4 additions & 4 deletions src/prng/isaac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
///
/// [`Hc128Rng`]: ../hc128/struct.Hc128Rng.html
#[derive(Clone, Debug)]
#[cfg_attr(feature="serde-1", derive(Serialize, Deserialize))]
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
pub struct IsaacRng(BlockRng<IsaacCore>);

impl RngCore for IsaacRng {
Expand Down Expand Up @@ -142,9 +142,9 @@ impl IsaacRng {

/// The core of `IsaacRng`, used with `BlockRng`.
#[derive(Clone)]
#[cfg_attr(feature="serde-1", derive(Serialize, Deserialize))]
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
pub struct IsaacCore {
#[cfg_attr(feature="serde-1",serde(with="super::isaac_array::isaac_array_serde"))]
#[cfg_attr(feature="serde1",serde(with="super::isaac_array::isaac_array_serde"))]
mem: [w32; RAND_SIZE],
a: w32,
b: w32,
Expand Down Expand Up @@ -456,7 +456,7 @@ mod test {
}

#[test]
#[cfg(all(feature="serde-1", feature="std"))]
#[cfg(all(feature="serde1", feature="std"))]
fn test_isaac_serde() {
use bincode;
use std::io::{BufWriter, BufReader};
Expand Down
8 changes: 4 additions & 4 deletions src/prng/isaac64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
/// [`IsaacRng`]: ../isaac/struct.IsaacRng.html
/// [`Hc128Rng`]: ../hc128/struct.Hc128Rng.html
#[derive(Clone, Debug)]
#[cfg_attr(feature="serde-1", derive(Serialize, Deserialize))]
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
pub struct Isaac64Rng(BlockRng64<Isaac64Core>);

impl RngCore for Isaac64Rng {
Expand Down Expand Up @@ -132,9 +132,9 @@ impl Isaac64Rng {

/// The core of `Isaac64Rng`, used with `BlockRng`.
#[derive(Clone)]
#[cfg_attr(feature="serde-1", derive(Serialize, Deserialize))]
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
pub struct Isaac64Core {
#[cfg_attr(feature="serde-1",serde(with="super::isaac_array::isaac_array_serde"))]
#[cfg_attr(feature="serde1",serde(with="super::isaac_array::isaac_array_serde"))]
mem: [w64; RAND_SIZE],
a: w64,
b: w64,
Expand Down Expand Up @@ -448,7 +448,7 @@ mod test {
}

#[test]
#[cfg(all(feature="serde-1", feature="std"))]
#[cfg(all(feature="serde1", feature="std"))]
fn test_isaac64_serde() {
use bincode;
use std::io::{BufWriter, BufReader};
Expand Down
10 changes: 5 additions & 5 deletions src/prng/isaac_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
// implement `AsRef`, `Default`, `Serialize`, `Deserialize`, or any other
// traits for that matter.

#[cfg(feature="serde-1")] use serde::{Serialize, Deserialize};
#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};

const RAND_SIZE_LEN: usize = 8;
const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;


#[derive(Copy, Clone)]
#[allow(missing_debug_implementations)]
#[cfg_attr(feature="serde-1", derive(Serialize, Deserialize))]
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
pub struct IsaacArray<T> {
#[cfg_attr(feature="serde-1",serde(with="isaac_array_serde"))]
#[cfg_attr(feature="serde-1", serde(bound(
#[cfg_attr(feature="serde1",serde(with="isaac_array_serde"))]
#[cfg_attr(feature="serde1", serde(bound(
serialize = "T: Serialize",
deserialize = "T: Deserialize<'de> + Copy + Default")))]
inner: [T; RAND_SIZE]
Expand Down Expand Up @@ -60,7 +60,7 @@ impl<T> ::core::default::Default for IsaacArray<T> where T: Copy + Default {
}


#[cfg(feature="serde-1")]
#[cfg(feature="serde1")]
pub(super) mod isaac_array_serde {
const RAND_SIZE_LEN: usize = 8;
const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
Expand Down
4 changes: 2 additions & 2 deletions src/prng/xorshift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use rand_core::{RngCore, SeedableRng, Error, impls, le};
/// RNGs"](https://www.jstatsoft.org/v08/i14/paper). *Journal of
/// Statistical Software*. Vol. 8 (Issue 14).
#[derive(Clone)]
#[cfg_attr(feature="serde-1", derive(Serialize,Deserialize))]
#[cfg_attr(feature="serde1", derive(Serialize,Deserialize))]
pub struct XorShiftRng {
x: w<u32>,
y: w<u32>,
Expand Down Expand Up @@ -195,7 +195,7 @@ mod tests {
}
}

#[cfg(all(feature="serde-1", feature="std"))]
#[cfg(all(feature="serde1", feature="std"))]
#[test]
fn test_xorshift_serde() {
use bincode;
Expand Down
6 changes: 3 additions & 3 deletions utils/ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ main() {
if [ ! -z $DISABLE_TESTS ]; then
cross build --all --no-default-features --target $TARGET --release
if [ -z $DISABLE_STD ]; then
cross build --features log,serde-1 --target $TARGET
cross build --features log,serde1 --target $TARGET
fi
return
fi

if [ ! -z $NIGHTLY ]; then
cross test --all --tests --no-default-features --features alloc --target $TARGET
cross test --features serde-1,log,nightly --target $TARGET
cross test --features serde1,log,nightly --target $TARGET
cross test --all --benches --target $TARGET
else
cross test --all --tests --no-default-features --target $TARGET
cross test --features serde-1,log --target $TARGET
cross test --features serde1,log --target $TARGET
fi
}

Expand Down

0 comments on commit ec6f5dd

Please sign in to comment.