Skip to content

Commit 579d7f3

Browse files
committed
Add VoidRng
1 parent a9c0e28 commit 579d7f3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,20 @@ mod test {
155155
// NOTE: Some distributions have tests checking only that samples can be
156156
// generated. This is redundant with vector and correctness tests.
157157

158+
/// An RNG which panics on first use
159+
pub struct VoidRng;
160+
impl rand::RngCore for VoidRng {
161+
fn next_u32(&mut self) -> u32 {
162+
panic!("usage of VoidRng")
163+
}
164+
fn next_u64(&mut self) -> u64 {
165+
panic!("usage of VoidRng")
166+
}
167+
fn fill_bytes(&mut self, _: &mut [u8]) {
168+
panic!("usage of VoidRng")
169+
}
170+
}
171+
158172
/// Construct a deterministic RNG with the given seed
159173
pub fn rng(seed: u64) -> impl rand::RngCore {
160174
// For tests, we want a statistically good, fast, reproducible RNG.

0 commit comments

Comments
 (0)