1use rand::{rngs::ThreadRng, Rng};
4
5use chandeliers_sem::traits::{Embed, Step};
6use chandeliers_sem::{implicit_clock, ty};
7
8#[derive(Debug, Default, Clone)]
11pub struct random_int {
12 rng: ThreadRng,
14}
15impl Step for random_int {
16 type Input = ();
17 type Output = i64;
18 fn step(&mut self, __inputs: ty!()) -> ty!(int) {
19 implicit_clock!(__inputs);
20 self.rng.gen::<i64>().embed()
21 }
22}
23
24#[derive(Debug, Default, Clone)]
27pub struct random_float {
28 rng: ThreadRng,
30}
31impl Step for random_float {
32 type Input = ();
33 type Output = f64;
34 fn step(&mut self, __inputs: ty!()) -> ty!(float) {
35 implicit_clock!(__inputs);
36 self.rng.gen::<f64>().embed()
37 }
38}
39
40#[derive(Debug, Default, Clone)]
42pub struct random_bool {
43 rng: ThreadRng,
45}
46impl Step for random_bool {
47 type Input = ();
48 type Output = bool;
49 fn step(&mut self, __inputs: ty!()) -> ty!(bool) {
50 implicit_clock!(__inputs);
51 self.rng.gen::<bool>().embed()
52 }
53}