Skip to content

Derive Clone for OsRng #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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