summaryrefslogtreecommitdiff
path: root/rand/src/rngs/thread.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-01-16 17:26:30 -0800
committerDaniel Mueller <deso@posteo.net>2019-01-16 17:26:30 -0800
commit8350ac6afb2d678b74581000a6aafe1994b72231 (patch)
tree2330da01a806921b3849c9e64d2b9f506495e2c0 /rand/src/rngs/thread.rs
parentd6652b913b33e432a748187f9f5623cec1e9926e (diff)
downloadnitrocli-8350ac6afb2d678b74581000a6aafe1994b72231.tar.gz
nitrocli-8350ac6afb2d678b74581000a6aafe1994b72231.tar.bz2
Update nitrokey crate to 0.3.3
This change updates the nitrokey crate to version 0.3.3. Along with that change we update rand to 0.6.4 because rand 0.6.1 does not yet contain a publicly accessible rand_os. Note that we no longer require all crates in rand's workspace, but only rand_os and rand_core, which is a significant reduction in the number of lines of code compiled. Import subrepo nitrokey/:nitrokey at 7cf747d56ddc0b7eeedc3caf36dcc909907a171c Import subrepo rand/:rand at 4336232dda03323634b10ec72ddf27914aebc3a2
Diffstat (limited to 'rand/src/rngs/thread.rs')
-rw-r--r--rand/src/rngs/thread.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/rand/src/rngs/thread.rs b/rand/src/rngs/thread.rs
index ff772e3..7977d85 100644
--- a/rand/src/rngs/thread.rs
+++ b/rand/src/rngs/thread.rs
@@ -87,10 +87,11 @@ thread_local!(
}
);
-/// Retrieve the lazily-initialized thread-local random number
-/// generator, seeded by the system. Intended to be used in method
-/// chaining style, e.g. `thread_rng().gen::<i32>()`, or cached locally, e.g.
-/// `let mut rng = thread_rng();`.
+/// Retrieve the lazily-initialized thread-local random number generator,
+/// seeded by the system. Intended to be used in method chaining style,
+/// e.g. `thread_rng().gen::<i32>()`, or cached locally, e.g.
+/// `let mut rng = thread_rng();`. Invoked by the `Default` trait, making
+/// `ThreadRng::default()` equivelent.
///
/// For more information see [`ThreadRng`].
///
@@ -99,6 +100,12 @@ pub fn thread_rng() -> ThreadRng {
ThreadRng { rng: THREAD_RNG_KEY.with(|t| t.get()) }
}
+impl Default for ThreadRng {
+ fn default() -> ThreadRng {
+ ::prelude::thread_rng()
+ }
+}
+
impl RngCore for ThreadRng {
#[inline(always)]
fn next_u32(&mut self) -> u32 {
@@ -125,7 +132,6 @@ impl CryptoRng for ThreadRng {}
#[cfg(test)]
mod test {
#[test]
- #[cfg(not(feature="stdweb"))]
fn test_thread_rng() {
use Rng;
let mut r = ::thread_rng();