random_constructible/
impl_for_optiont.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
crate::ix!();

impl<T: RandConstruct> RandConstruct for Option<T> {
    fn random() -> Self {
        if rand::random::<f64>() < 0.5 {
            Some(T::random())
        } else {
            None
        }
    }

    fn uniform() -> Self {
        if rand::random::<f64>() < 0.5 {
            Some(T::uniform())
        } else {
            None
        }
    }

    fn random_with_rng<R: Rng + ?Sized>(rng: &mut R) -> Self {
        if rand::random::<f64>() < 0.5 {
            Some(T::random_with_rng(rng))
        } else {
            None
        }
    }
}