Skip to content

Commit a7441ff

Browse files
committed
Move OsRng definition to rand::rngs
Also removes std, os_rng features from rand_core
1 parent caeacc5 commit a7441ff

File tree

3 files changed

+6
-134
lines changed

3 files changed

+6
-134
lines changed

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ rustdoc-args = ["--generate-link-to-definition"]
2525
all-features = true
2626

2727
[features]
28-
std = ["getrandom?/std"]
29-
os_rng = ["dep:getrandom"]
3028
serde = ["dep:serde"] # enables serde for BlockRng wrapper
3129

3230
[dependencies]
3331
serde = { version = "1", features = ["derive"], optional = true }
34-
getrandom = { version = "0.3.0", optional = true }

src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,10 @@
3636
#![cfg_attr(docsrs, feature(doc_cfg))]
3737
#![no_std]
3838

39-
#[cfg(feature = "std")]
40-
extern crate std;
41-
4239
use core::{fmt, ops::DerefMut};
4340

4441
pub mod block;
4542
pub mod le;
46-
#[cfg(feature = "os_rng")]
47-
mod os;
48-
49-
#[cfg(feature = "os_rng")]
50-
pub use os::{OsError, OsRng};
5143

5244
/// Implementation-level interface for RNGs
5345
///
@@ -168,6 +160,8 @@ where
168160
/// An optional property of CSPRNGs is backtracking resistance: if the CSPRNG's
169161
/// state is revealed, it will not be computationally-feasible to reconstruct
170162
/// prior output values. This property is not required by `CryptoRng`.
163+
///
164+
/// [`OsRng`]: https://docs.rs/rand/latest/rand/rngs/struct.OsRng.html
171165
pub trait CryptoRng: RngCore {}
172166

173167
impl<T: DerefMut> CryptoRng for T where T::Target: CryptoRng {}
@@ -184,6 +178,8 @@ impl<T: DerefMut> CryptoRng for T where T::Target: CryptoRng {}
184178
/// An implementation of this trait may be made compatible with code requiring
185179
/// an [`RngCore`] through [`TryRngCore::unwrap_err`]. The resulting RNG will
186180
/// panic in case the underlying fallible RNG yields an error.
181+
///
182+
/// [`OsRng`]: https://docs.rs/rand/latest/rand/rngs/struct.OsRng.html
187183
pub trait TryRngCore {
188184
/// The type returned in the event of a RNG error.
189185
type Error: fmt::Debug + fmt::Display;
@@ -246,6 +242,8 @@ impl<R: RngCore + ?Sized> TryRngCore for R {
246242
/// `default()` instances are themselves secure generators: for example if the
247243
/// implementing type is a stateless interface over a secure external generator
248244
/// (like [`OsRng`]) or if the `default()` instance uses a strong, fresh seed.
245+
///
246+
/// [`OsRng`]: https://docs.rs/rand/latest/rand/rngs/struct.OsRng.html
249247
pub trait TryCryptoRng: TryRngCore {}
250248

251249
impl<R: CryptoRng + ?Sized> TryCryptoRng for R {}

src/os.rs

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)