Shared Rust kernels
catalogue/random
All modules · quoted at commit 9e1884369a67 of DnaCalc/DnaCalc. Comments are the source's own.
draw · 12 lines · calc-func/src/catalogue/random.rs on GitHub/// The next number of the services' random source, in [0, 1).
fn draw(site: &Site<'_>, sv: &mut EvalServices<'_>) -> Step<f64> {
let Some(source) = sv.random() else {
return Err(site.not_modelled(None));
};
let unit = source.next_unit();
if unit.is_finite() && (0.0..1.0).contains(&unit) {
Ok(unit)
} else {
Err(site.not_modelled(None))
}
}
Used by 3 functions.