pub struct LinearCongruentialGenerator { /* private fields */ }Implementations§
source§impl LinearCongruentialGenerator
impl LinearCongruentialGenerator
sourcepub fn from_seed(seed: &[u8]) -> Self
pub fn from_seed(seed: &[u8]) -> Self
Examples found in repository?
examples/example.rs (line 7)
2 3 4 5 6 7 8 9 10 11 12 13
fn example_random() {
let rand = system_random();
println!("A random number = {}", rand);
let seed = b"a seed";
let mut rnd = LinearCongruentialGenerator::from_seed(seed);
let rand2 = rnd.generate_u8();
println!("Another random number from seed {}", rand2);
let random_str = rnd.generate_random_string(20);
println!("A random String = {}", random_str);
}pub fn reset(&mut self)
pub fn generate(&mut self) -> u32
sourcepub fn generate_u8(&mut self) -> u8
pub fn generate_u8(&mut self) -> u8
Examples found in repository?
examples/example.rs (line 8)
2 3 4 5 6 7 8 9 10 11 12 13
fn example_random() {
let rand = system_random();
println!("A random number = {}", rand);
let seed = b"a seed";
let mut rnd = LinearCongruentialGenerator::from_seed(seed);
let rand2 = rnd.generate_u8();
println!("Another random number from seed {}", rand2);
let random_str = rnd.generate_random_string(20);
println!("A random String = {}", random_str);
}pub fn rand_range(&mut self, range: Range<usize>) -> usize
sourcepub fn generate_random_string(&mut self, len: usize) -> String
pub fn generate_random_string(&mut self, len: usize) -> String
Examples found in repository?
examples/example.rs (line 11)
2 3 4 5 6 7 8 9 10 11 12 13
fn example_random() {
let rand = system_random();
println!("A random number = {}", rand);
let seed = b"a seed";
let mut rnd = LinearCongruentialGenerator::from_seed(seed);
let rand2 = rnd.generate_u8();
println!("Another random number from seed {}", rand2);
let random_str = rnd.generate_random_string(20);
println!("A random String = {}", random_str);
}Trait Implementations§
source§impl Clone for LinearCongruentialGenerator
impl Clone for LinearCongruentialGenerator
source§fn clone(&self) -> LinearCongruentialGenerator
fn clone(&self) -> LinearCongruentialGenerator
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for LinearCongruentialGenerator
impl RefUnwindSafe for LinearCongruentialGenerator
impl Send for LinearCongruentialGenerator
impl Sync for LinearCongruentialGenerator
impl Unpin for LinearCongruentialGenerator
impl UnwindSafe for LinearCongruentialGenerator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)