Skip to content

Commit

Permalink
Merge pull request #703 from dhardy/master
Browse files Browse the repository at this point in the history
Disable std feature by default in rand_core and rand_jitter
  • Loading branch information
dhardy committed Jan 25, 2019
2 parents c864540 + 77e952f commit 8112daa
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -46,9 +46,9 @@ members = [
]

[dependencies]
rand_core = { path = "rand_core", version = "0.3", default-features = false }
rand_core = { path = "rand_core", version = "0.4" }
rand_pcg = { path = "rand_pcg", version = "0.1" }
rand_jitter = { path = "rand_jitter", version = "0.1", default-features = false }
rand_jitter = { path = "rand_jitter", version = "0.1" }
rand_os = { path = "rand_os", version = "0.1", optional = true }
# only for deprecations and benches:
rand_isaac = { path = "rand_isaac", version = "0.1" }
Expand Down Expand Up @@ -84,4 +84,4 @@ autocfg = "0.1"
all-features = true

[patch.crates-io]
rand_core = { path = "rand_core", version = "0.3", default-features = false }
rand_core = { path = "rand_core", version = "0.4" }
7 changes: 0 additions & 7 deletions appveyor.yml
Expand Up @@ -37,13 +37,6 @@ test_script:
- cargo test --features=serde1,log
- cargo test --benches --features=nightly
- cargo test --examples
- cargo test --package rand_core
- cargo test --package rand_core --no-default-features --features=alloc
- cargo test --package rand_isaac --features=serde1
- cargo test --package rand_xorshift --features=serde1
- cargo test --package rand_xoshiro
- cargo test --package rand_chacha
- cargo test --package rand_hc
- cargo test --manifest-path rand_core/Cargo.toml
- cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc
- cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1
Expand Down
2 changes: 1 addition & 1 deletion rand_chacha/Cargo.toml
Expand Up @@ -19,7 +19,7 @@ travis-ci = { repository = "rust-random/rand" }
appveyor = { repository = "rust-random/rand" }

[dependencies]
rand_core = { path = "../rand_core", version = ">=0.2, <0.4", default-features=false }
rand_core = { path = "../rand_core", version = "0.4" }

[build-dependencies]
autocfg = "0.1"
3 changes: 3 additions & 0 deletions rand_core/CHANGELOG.md
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.0] - 2019-01-24
- Disable the `std` feature by default (#702)

## [0.3.0] - 2018-09-24
- Add `SeedableRng::seed_from_u64` for convenient seeding. (#537)

Expand Down
3 changes: 1 addition & 2 deletions rand_core/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rand_core"
version = "0.3.0"
version = "0.4.0"
authors = ["The Rand Project Developers", "The Rust Project Developers"]
license = "MIT/Apache-2.0"
readme = "README.md"
Expand All @@ -18,7 +18,6 @@ travis-ci = { repository = "rust-random/rand" }
appveyor = { repository = "rust-random/rand" }

[features]
default = ["std"]
std = ["alloc"] # use std library; should be default but for above bug
alloc = [] # enables Vec and Box support without std
serde1 = ["serde", "serde_derive"] # enables serde for BlockRng wrapper
Expand Down
11 changes: 6 additions & 5 deletions rand_core/README.md
Expand Up @@ -44,13 +44,14 @@ The traits and error types are also available via `rand`.

`rand_core` supports `no_std` and `alloc`-only configurations, as well as full
`std` functionality. The differences between `no_std` and full `std` are small,
comprising `RngCore` support for `Box<R>` types where `R: RngCore`, as well as
comprising `RngCore` support for `Box<R>` types where `R: RngCore`,
`std::io::Read` support for types supporting `RngCore`, and
extensions to the `Error` type's functionality.

Due to [rust-lang/cargo#1596](https://github.com/rust-lang/cargo/issues/1596),
`rand_core` is built without `std` support by default. Since features are
unioned across the whole dependency tree, any crate using `rand` with its
default features will also enable `std` support in `rand_core`.
The `std` feature is *not enabled by default*. This is primarily to avoid build
problems where one crate implicitly requires `rand_core` with `std` support and
another crate requires `rand` *without* `std` support. However, the `rand` crate
continues to enable `std` support by default, both for itself and `rand_core`.

The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG
implementations that use the `BlockRng` or `BlockRng64` wrappers.
Expand Down
2 changes: 1 addition & 1 deletion rand_hc/Cargo.toml
Expand Up @@ -18,4 +18,4 @@ travis-ci = { repository = "rust-random/rand" }
appveyor = { repository = "rust-random/rand" }

[dependencies]
rand_core = { path = "../rand_core", version = ">=0.2, <0.4", default-features=false }
rand_core = { path = "../rand_core", version = "0.4" }
2 changes: 1 addition & 1 deletion rand_isaac/Cargo.toml
Expand Up @@ -21,7 +21,7 @@ appveyor = { repository = "rust-random/rand" }
serde1 = ["serde", "serde_derive", "rand_core/serde1"]

[dependencies]
rand_core = { path = "../rand_core", version = "0.3", default-features=false }
rand_core = { path = "../rand_core", version = "0.4" }
serde = { version = "1", optional = true }
serde_derive = { version = "^1.0.38", optional = true }

Expand Down
2 changes: 1 addition & 1 deletion rand_jitter/CHANGELOG.md
Expand Up @@ -4,5 +4,5 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2019-01-04
## [0.1.0] - 2019-01-24
Initial release.
6 changes: 2 additions & 4 deletions rand_jitter/Cargo.toml
Expand Up @@ -14,7 +14,7 @@ travis-ci = { repository = "rust-random/rand" }
appveyor = { repository = "rust-random/rand" }

[dependencies]
rand_core = { path = "../rand_core", version = "0.3", default-features = false }
rand_core = { path = "../rand_core", version = "0.4" }
log = { version = "0.4", optional = true }

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
Expand All @@ -24,6 +24,4 @@ libc = "0.2"
winapi = { version = "0.3", features = ["profileapi"] }

[features]
default = ["std"]
std = []

std = ["rand_core/std"]
6 changes: 6 additions & 0 deletions rand_jitter/README.md
Expand Up @@ -22,6 +22,12 @@ Links:
- [API documentation (docs.rs)](https://docs.rs/rand_jitter)
- [Changelog](CHANGELOG.md)

## Features

This crate has optional `std` support which is *disabled by default*;
this feature is required to provide the `JitterRng::new` function;
without `std` support a timer must be supplied via `JitterRng::new_with_timer`.

## Quality testing

`JitterRng::new()` has build-in, but limited, quality testing, however
Expand Down
2 changes: 2 additions & 0 deletions rand_jitter/tests/mod.rs
Expand Up @@ -2,8 +2,10 @@ extern crate rand_jitter;
extern crate rand_core;

use rand_jitter::JitterRng;
#[cfg(feature = "std")]
use rand_core::RngCore;

#[cfg(feature = "std")]
#[test]
fn test_jitter_init() {
// Because this is a debug build, measurements here are not representive
Expand Down
2 changes: 1 addition & 1 deletion rand_os/Cargo.toml
Expand Up @@ -15,7 +15,7 @@ travis-ci = { repository = "rust-random/rand" }
appveyor = { repository = "rust-random/rand" }

[dependencies]
rand_core = { path = "../rand_core", version = "0.3", default-features = false }
rand_core = { path = "../rand_core", version = "0.4", features = ["std"] }
log = { version = "0.4", optional = true }

[target.'cfg(unix)'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rand_pcg/Cargo.toml
Expand Up @@ -22,7 +22,7 @@ appveyor = { repository = "rust-random/rand" }
serde1 = ["serde", "serde_derive"]

[dependencies]
rand_core = { path = "../rand_core", version = "0.3", default-features=false }
rand_core = { path = "../rand_core", version = "0.4" }
serde = { version = "1", optional = true }
serde_derive = { version = "^1.0.38", optional = true }

Expand Down
2 changes: 1 addition & 1 deletion rand_xorshift/Cargo.toml
Expand Up @@ -21,7 +21,7 @@ appveyor = { repository = "rust-random/rand" }
serde1 = ["serde", "serde_derive"]

[dependencies]
rand_core = { path = "../rand_core", version = ">=0.2, <0.4", default-features=false }
rand_core = { path = "../rand_core", version = "0.4" }
serde = { version = "1", optional = true }
serde_derive = { version = "^1.0.38", optional = true }

Expand Down
2 changes: 1 addition & 1 deletion rand_xoshiro/Cargo.toml
Expand Up @@ -13,7 +13,7 @@ categories = ["algorithms"]

[dependencies]
byteorder = { version = "1", default-features=false }
rand_core = { path = "../rand_core", version = "0.3", default-features=false }
rand_core = { path = "../rand_core", version = "0.4" }

[dev-dependencies]
rand = { path = "..", version = "0.6", default-features=false } # needed for doctests

0 comments on commit 8112daa

Please sign in to comment.