Skip to content

Commit

Permalink
Merge pull request rust-random#384 from pitdicker/clone_osrng
Browse files Browse the repository at this point in the history
Derive Clone for OsRng
  • Loading branch information
pitdicker committed Apr 11, 2018
2 parents d0003ed + bd6a62d commit 95ea68c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ use rand_core::{RngCore, Error, impls};
/// [`EntropyRng`]: struct.EntropyRng.html

#[allow(unused)] // not used by all targets
#[derive(Clone)]
pub struct OsRng(imp::OsRng);

impl fmt::Debug for OsRng {
Expand Down Expand Up @@ -149,10 +150,10 @@ mod imp {
use std::io::Read;
use std::sync::{Once, Mutex, ONCE_INIT};

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng(OsRngMethod);

#[derive(Debug)]
#[derive(Clone, Debug)]
enum OsRngMethod {
GetRandom,
RandomDevice,
Expand Down Expand Up @@ -373,7 +374,7 @@ mod imp {

use {Error, ErrorKind};

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng;

impl OsRng {
Expand Down Expand Up @@ -408,7 +409,7 @@ mod imp {
use std::io;
use self::libc::{c_int, size_t};

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng;

enum SecRandom {}
Expand Down Expand Up @@ -452,7 +453,7 @@ mod imp {
use std::ptr;
use std::io;

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng;

impl OsRng {
Expand Down Expand Up @@ -490,7 +491,7 @@ mod imp {

use std::io;

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng;

impl OsRng {
Expand Down Expand Up @@ -524,7 +525,7 @@ mod imp {
use std::io::ErrorKind::*;
use std::sync::{Once, Mutex, ONCE_INIT};

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng();

// TODO: remove outer Option when `Mutex::new(None)` is a constant expression
Expand Down Expand Up @@ -584,7 +585,7 @@ mod imp {

use std::io;

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng;

impl OsRng {
Expand Down Expand Up @@ -624,7 +625,7 @@ mod imp {
use self::winapi::um::ntsecapi::RtlGenRandom;
use self::winapi::um::winnt::PVOID;

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng;

impl OsRng {
Expand Down Expand Up @@ -657,7 +658,7 @@ mod imp {
mod imp {
use {Error, ErrorKind};

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng;

impl OsRng {
Expand All @@ -682,13 +683,13 @@ mod imp {
use stdweb::web::error::Error as WebError;
use {Error, ErrorKind};

#[derive(Debug)]
#[derive(Clone, Debug)]
enum OsRngInner {
Browser,
Node
}

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct OsRng(OsRngInner);

impl OsRng {
Expand Down

0 comments on commit 95ea68c

Please sign in to comment.