macro_rules! random_fill { ($($proc_macro:tt)*) => { ... }; }
Expand description
Generate random numbers.
ยงExamples
let mut f = [0f64; 100];
random_number::random_fill!(f);
for f in f.iter().copied() {
assert!(0.0 <= f && f <= 1.0);
}
let mut i = [0u8; 100];
random_number::random_fill!(i);
for i in i.iter().copied() {
assert!(0 <= i && i <= 255);
}
use random_number::rand;
let mut thread_rng = rand::thread_rng();
let mut f = [0f64; 100];
random_number::random_fill!(f, thread_rng);
for f in f.iter().copied() {
assert!(0.0 <= f && f <= 1.0);
}
let mut i = [0u8; 100];
random_number::random_fill!(i, thread_rng);
for i in i.iter().copied() {
assert!(0 <= i && i <= 255);
}
let mut i = [0u8; 100];
random_number::random_fill!(i, ..=10);
for i in i.iter().copied() {
assert!(0 <= i && i <= 10);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, ..=0);
for i in i.iter().copied() {
assert!(-128 <= i && i <= 0);
}
use random_number::rand;
let mut thread_rng = rand::thread_rng();
let mut i = [0u8; 100];
random_number::random_fill!(i, ..=10, thread_rng);
for i in i.iter().copied() {
assert!(0 <= i && i <= 10);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, ..=0, thread_rng);
for i in i.iter().copied() {
assert!(-128 <= i && i <= 0);
}
let mut i = [0u8; 100];
random_number::random_fill!(i, 10..);
for i in i.iter().copied() {
assert!(10 <= i && i <= 255);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, 0..);
for i in i.iter().copied() {
assert!(0 <= i && i <= 127);
}
use random_number::rand;
let mut thread_rng = rand::thread_rng();
let mut i = [0u8; 100];
random_number::random_fill!(i, 10.., thread_rng);
for i in i.iter().copied() {
assert!(10 <= i && i <= 255);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, 0.., thread_rng);
for i in i.iter().copied() {
assert!(0 <= i && i <= 127);
}
let mut i = [0u8; 100];
random_number::random_fill!(i, ..10);
for i in i.iter().copied() {
assert!(0 <= i && i <= 9);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, ..0);
for i in i.iter().copied() {
assert!(-128 <= i && i <= -1);
}
use random_number::rand;
let mut thread_rng = rand::thread_rng();
let mut i = [0u8; 100];
random_number::random_fill!(i, ..10, thread_rng);
for i in i.iter().copied() {
assert!(0 <= i && i <= 9);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, ..0, thread_rng);
for i in i.iter().copied() {
assert!(-128 <= i && i <= -1);
}
let mut i = [0u8; 100];
random_number::random_fill!(i, 1..10);
for i in i.iter().copied() {
assert!(1 <= i && i <= 10);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, -2..12);
for i in i.iter().copied() {
assert!(-2 <= i && i <= 12);
}
use random_number::rand;
let mut thread_rng = rand::thread_rng();
let mut i = [0u8; 100];
random_number::random_fill!(i, 1..10, thread_rng);
for i in i.iter().copied() {
assert!(1 <= i && i <= 10);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, -2..12, thread_rng);
for i in i.iter().copied() {
assert!(-2 <= i && i <= 12);
}
let mut i = [0u8; 100];
random_number::random_fill!(i, 12, 20);
for i in i.iter().copied() {
assert!(12 <= i && i <= 20);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, 12, 20);
for i in i.iter().copied() {
assert!(12 <= i && i <= 20);
}
use random_number::rand;
let mut thread_rng = rand::thread_rng();
let mut i = [0u8; 100];
random_number::random_fill!(i, 12, 20, thread_rng);
for i in i.iter().copied() {
assert!(12 <= i && i <= 20);
}
let mut i = [0i8; 100];
random_number::random_fill!(i, 12, 20, thread_rng);
for i in i.iter().copied() {
assert!(12 <= i && i <= 20);
}