Debug impls for non-distribution public types
diff --git a/src/chacha.rs b/src/chacha.rs
index a347ec5..1acec5e 100644
--- a/src/chacha.rs
+++ b/src/chacha.rs
@@ -26,7 +26,7 @@
///
/// [1]: D. J. Bernstein, [*ChaCha, a variant of
/// Salsa20*](http://cr.yp.to/chacha.html)
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Debug)]
pub struct ChaChaRng {
buffer: [w32; STATE_WORDS], // Internal buffer of output
state: [w32; STATE_WORDS], // Initial state
diff --git a/src/distributions/mod.rs b/src/distributions/mod.rs
index 50f9d95..8a9e6d2 100644
--- a/src/distributions/mod.rs
+++ b/src/distributions/mod.rs
@@ -17,6 +17,8 @@
//! internally. The `IndependentSample` trait is for generating values
//! that do not need to record state.
+#![allow(missing_debug_implementations)]
+
use std::marker;
use {Rng, Rand};
diff --git a/src/isaac.rs b/src/isaac.rs
index 42de352..b70a8e6 100644
--- a/src/isaac.rs
+++ b/src/isaac.rs
@@ -15,6 +15,7 @@
use std::slice;
use std::iter::repeat;
use std::num::Wrapping as w;
+use std::fmt;
use {Rng, SeedableRng, Rand, w32, w64};
@@ -260,6 +261,12 @@
}
}
+impl fmt::Debug for IsaacRng {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "IsaacRng {{}}")
+ }
+}
+
const RAND_SIZE_64_LEN: usize = 8;
const RAND_SIZE_64: usize = 1 << RAND_SIZE_64_LEN;
@@ -503,6 +510,11 @@
}
}
+impl fmt::Debug for Isaac64Rng {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "Isaac64Rng {{}}")
+ }
+}
#[cfg(test)]
mod test {
diff --git a/src/lib.rs b/src/lib.rs
index 472e4ec..955a3c8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -241,8 +241,11 @@
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/rand/")]
+#![deny(missing_debug_implementations)]
+
#[cfg(test)] #[macro_use] extern crate log;
+
use std::cell::RefCell;
use std::marker;
use std::mem;
@@ -604,6 +607,7 @@
///
/// [`gen_iter`]: trait.Rng.html#method.gen_iter
/// [`Rng`]: trait.Rng.html
+#[derive(Debug)]
pub struct Generator<'a, T, R:'a> {
rng: &'a mut R,
_marker: marker::PhantomData<fn() -> T>,
@@ -623,6 +627,7 @@
///
/// [`gen_ascii_chars`]: trait.Rng.html#method.gen_ascii_chars
/// [`Rng`]: trait.Rng.html
+#[derive(Debug)]
pub struct AsciiGenerator<'a, R:'a> {
rng: &'a mut R,
}
@@ -682,7 +687,7 @@
/// RNGs"](http://www.jstatsoft.org/v08/i14/paper). *Journal of
/// Statistical Software*. Vol. 8 (Issue 14).
#[allow(missing_copy_implementations)]
-#[derive(Clone)]
+#[derive(Clone, Debug)]
pub struct XorShiftRng {
x: w32,
y: w32,
@@ -772,6 +777,7 @@
/// let Open01(val) = random::<Open01<f32>>();
/// println!("f32 from (0,1): {}", val);
/// ```
+#[derive(Debug)]
pub struct Open01<F>(pub F);
/// A wrapper for generating floating point numbers uniformly in the
@@ -789,11 +795,12 @@
/// let Closed01(val) = random::<Closed01<f32>>();
/// println!("f32 from [0,1]: {}", val);
/// ```
+#[derive(Debug)]
pub struct Closed01<F>(pub F);
/// The standard RNG. This is designed to be efficient on the current
/// platform.
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Debug)]
pub struct StdRng {
rng: IsaacWordRng,
}
@@ -856,6 +863,7 @@
}
/// Controls how the thread-local RNG is reseeded.
+#[derive(Debug)]
struct ThreadRngReseeder;
impl reseeding::Reseeder<StdRng> for ThreadRngReseeder {
@@ -870,7 +878,7 @@
type ThreadRngInner = reseeding::ReseedingRng<StdRng, ThreadRngReseeder>;
/// The thread-local RNG.
-#[derive(Clone)]
+#[derive(Clone, Debug)]
pub struct ThreadRng {
rng: Rc<RefCell<ThreadRngInner>>,
}
diff --git a/src/os.rs b/src/os.rs
index e9ab758..acb112c 100644
--- a/src/os.rs
+++ b/src/os.rs
@@ -11,7 +11,7 @@
//! Interfaces to the operating system provided random number
//! generators.
-use std::{io, mem};
+use std::{io, mem, fmt};
use Rng;
/// A random number generator that retrieves randomness straight from
@@ -42,6 +42,12 @@
fn fill_bytes(&mut self, v: &mut [u8]) { self.0.fill_bytes(v) }
}
+impl fmt::Debug for OsRng {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "OsRng {{}}")
+ }
+}
+
fn next_u32(mut fill_buf: &mut FnMut(&mut [u8])) -> u32 {
let mut buf: [u8; 4] = [0; 4];
fill_buf(&mut buf);
@@ -213,6 +219,7 @@
use Rng;
use self::libc::{c_int, size_t};
+ #[derive(Debug)]
pub struct OsRng;
enum SecRandom {}
@@ -259,6 +266,7 @@
use super::{next_u32, next_u64};
+ #[derive(Debug)]
pub struct OsRng;
impl OsRng {
@@ -302,6 +310,7 @@
use super::{next_u32, next_u64};
+ #[derive(Debug)]
pub struct OsRng;
impl OsRng {
@@ -339,6 +348,7 @@
use Rng;
use read::ReadRng;
+ #[derive(Debug)]
pub struct OsRng {
inner: ReadRng<File>,
}
@@ -396,6 +406,7 @@
fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL;
}
+ #[derive(Debug)]
pub struct OsRng {
hcryptprov: HCRYPTPROV
}
@@ -463,6 +474,7 @@
use super::{next_u32, next_u64};
+ #[derive(Debug)]
pub struct OsRng(extern fn(dest: *mut libc::c_void,
bytes: libc::size_t,
read: *mut libc::size_t) -> libc::c_int);
diff --git a/src/read.rs b/src/read.rs
index 9e420bc..c7351b7 100644
--- a/src/read.rs
+++ b/src/read.rs
@@ -30,6 +30,7 @@
/// let mut rng = read::ReadRng::new(&data[..]);
/// println!("{:x}", rng.gen::<u32>());
/// ```
+#[derive(Debug)]
pub struct ReadRng<R> {
reader: R
}
diff --git a/src/reseeding.rs b/src/reseeding.rs
index 39e464d..2fba9f4 100644
--- a/src/reseeding.rs
+++ b/src/reseeding.rs
@@ -21,6 +21,7 @@
/// A wrapper around any RNG which reseeds the underlying RNG after it
/// has generated a certain number of random bytes.
+#[derive(Debug)]
pub struct ReseedingRng<R, Rsdr> {
rng: R,
generation_threshold: u64,
@@ -132,7 +133,7 @@
/// Reseed an RNG using a `Default` instance. This reseeds by
/// replacing the RNG with the result of a `Default::default` call.
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
pub struct ReseedWithDefault;
impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {