You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
886 B
Plaintext
35 lines
886 B
Plaintext
---
|
|
source: tests/output.rs
|
|
expression: "get_stdout(&[\"-e\", item])"
|
|
---
|
|
rand_core Trait rand_core::RngCore rusty-man
|
|
|
|
EXAMPLES
|
|
A simple example, obviously not generating very *random* output:
|
|
|
|
#![allow(dead_code)]
|
|
use rand_core::{RngCore, Error, impls};
|
|
|
|
struct CountingRng(u64);
|
|
|
|
impl RngCore for CountingRng {
|
|
fn next_u32(&mut self) -> u32 {
|
|
self.next_u64() as u32
|
|
}
|
|
|
|
fn next_u64(&mut self) -> u64 {
|
|
self.0 += 1;
|
|
self.0
|
|
}
|
|
|
|
fn fill_bytes(&mut self, dest: &mut [u8]) {
|
|
impls::fill_bytes_via_next(self, dest)
|
|
}
|
|
|
|
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
|
|
Ok(self.fill_bytes(dest))
|
|
}
|
|
}
|
|
|
|
|