Skip to content

Commit 64b7273

Browse files
committed
Derive Clone for OsRng
1 parent 628a952 commit 64b7273

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/os.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use rand_core::{RngCore, Error, impls};
5656
/// [`EntropyRng`]: struct.EntropyRng.html
5757
5858
#[allow(unused)] // not used by all targets
59+
#[derive(Clone)]
5960
pub struct OsRng(imp::OsRng);
6061

6162
impl fmt::Debug for OsRng {
@@ -149,10 +150,10 @@ mod imp {
149150
use std::io::Read;
150151
use std::sync::{Once, Mutex, ONCE_INIT};
151152

152-
#[derive(Debug)]
153+
#[derive(Clone, Debug)]
153154
pub struct OsRng(OsRngMethod);
154155

155-
#[derive(Debug)]
156+
#[derive(Clone, Debug)]
156157
enum OsRngMethod {
157158
GetRandom,
158159
RandomDevice,
@@ -373,7 +374,7 @@ mod imp {
373374

374375
use {Error, ErrorKind};
375376

376-
#[derive(Debug)]
377+
#[derive(Clone, Debug)]
377378
pub struct OsRng;
378379

379380
impl OsRng {
@@ -408,7 +409,7 @@ mod imp {
408409
use std::io;
409410
use self::libc::{c_int, size_t};
410411

411-
#[derive(Debug)]
412+
#[derive(Clone, Debug)]
412413
pub struct OsRng;
413414

414415
enum SecRandom {}
@@ -452,7 +453,7 @@ mod imp {
452453
use std::ptr;
453454
use std::io;
454455

455-
#[derive(Debug)]
456+
#[derive(Clone, Debug)]
456457
pub struct OsRng;
457458

458459
impl OsRng {
@@ -490,7 +491,7 @@ mod imp {
490491

491492
use std::io;
492493

493-
#[derive(Debug)]
494+
#[derive(Clone, Debug)]
494495
pub struct OsRng;
495496

496497
impl OsRng {
@@ -524,7 +525,7 @@ mod imp {
524525
use std::io::ErrorKind::*;
525526
use std::sync::{Once, Mutex, ONCE_INIT};
526527

527-
#[derive(Debug)]
528+
#[derive(Clone, Debug)]
528529
pub struct OsRng();
529530

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

585586
use std::io;
586587

587-
#[derive(Debug)]
588+
#[derive(Clone, Debug)]
588589
pub struct OsRng;
589590

590591
impl OsRng {
@@ -624,7 +625,7 @@ mod imp {
624625
use self::winapi::um::ntsecapi::RtlGenRandom;
625626
use self::winapi::um::winnt::PVOID;
626627

627-
#[derive(Debug)]
628+
#[derive(Clone, Debug)]
628629
pub struct OsRng;
629630

630631
impl OsRng {
@@ -657,7 +658,7 @@ mod imp {
657658
mod imp {
658659
use {Error, ErrorKind};
659660

660-
#[derive(Debug)]
661+
#[derive(Clone, Debug)]
661662
pub struct OsRng;
662663

663664
impl OsRng {
@@ -682,13 +683,13 @@ mod imp {
682683
use stdweb::web::error::Error as WebError;
683684
use {Error, ErrorKind};
684685

685-
#[derive(Debug)]
686+
#[derive(Clone, Debug)]
686687
enum OsRngInner {
687688
Browser,
688689
Node
689690
}
690691

691-
#[derive(Debug)]
692+
#[derive(Clone, Debug)]
692693
pub struct OsRng(OsRngInner);
693694

694695
impl OsRng {

0 commit comments

Comments
 (0)