Skip to content

Commit

Permalink
Implement Default for OsRng
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Apr 6, 2019
1 parent b83a4c5 commit f84dccb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion rand_os/src/lib.rs
Expand Up @@ -55,7 +55,7 @@ use rand_core::{CryptoRng, RngCore, Error, ErrorKind, impls};
/// ```
///
/// [getrandom]: https://crates.io/crates/getrandom
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Default)]
pub struct OsRng;

impl OsRng {
Expand Down Expand Up @@ -100,3 +100,9 @@ fn test_os_rng() {
assert!(x != 0);
assert!(x != y);
}

#[test]
fn test_construction() {
let mut rng = OsRng::default();
assert!(rng.next_u64() != 0);
}
2 changes: 1 addition & 1 deletion src/rngs/os.rs
Expand Up @@ -31,7 +31,7 @@ use rand_core::{CryptoRng, RngCore, Error, ErrorKind, impls};
/// ```
///
/// [getrandom]: https://crates.io/crates/getrandom
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Default)]
pub struct OsRng;

impl OsRng {
Expand Down

0 comments on commit f84dccb

Please sign in to comment.