use rand_gen::*;
use rand::prelude::*;
static FIRST_NAMES: [&str; 3] = ["Test Name", "Test Name 2", "Test Name 3"];
fn test<R: Rng + ?Sized>(rng: &mut R) -> String {
FIRST_NAMES.choose(rng).unwrap().to_string()
}
fn gen_position<R: Rng + ?Sized>(rng: &mut R) -> i32 {
rng.gen_range(-500..=500)
}
#[derive(RandGen, Debug)]
struct Position {
#[rand_gen(method = "gen_position")]
_x: i32,
#[rand_gen(method = "gen_position")]
_y: i32,
}
#[derive(RandGen, Debug)]
struct RandomTest {
_val: i32,
#[rand_gen(method = "test")]
_custom_val: String,
_position: Position,
}
fn main() {
for _ in 0..500 {
let mut thread_rng = rand::thread_rng();
println!("{:?}", RandomTest::random(&mut thread_rng));
}
}