time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

commit 520ff9534be1c53eb4b6a006d7ad883d51a9054a
parent 130e1db2bcf292c6137cdfa576cd31377d811eb7
Author: NunoSempere <nuno.semperelh@protonmail.com>
Date:   Sun,  7 Apr 2024 21:12:50 -0400

remove extraneous return statements

leave the f64 declaration

Diffstat:
Mrust/src/main.rs | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/rust/src/main.rs b/rust/src/main.rs @@ -12,7 +12,7 @@ fn sample_to(low: f64, high: f64, mut rng: &mut Pcg64Mcg) -> f64 { let lognormal = LogNormal::new(normal_mean, normal_std).unwrap(); let x = lognormal.sample(&mut rng); // https://docs.rs/rand_distr/latest/src/rand_distr/normal.rs.html#232-236 - return x; + x; } fn model(mut rng: &mut Pcg64Mcg) -> f64 { @@ -25,15 +25,13 @@ fn model(mut rng: &mut Pcg64Mcg) -> f64 { let uniform = Uniform::new(0.0, 1.0); /* I don't understand why this doesn't need to be unwrapped, unlike normal below */ let p: f64 = uniform.sample(&mut rng); if p < ws[0] { - return 0.0; + 0.0; } else if p < (ws[0] + ws[1]) { - return 1.0; + 1.0; } else if p < (ws[0] + ws[1] + ws[2]) { - let x = sample_to(1.0, 3.0, rng); - return x; + sample_to(1.0, 3.0, rng); } else { - let x = sample_to(2.0, 10.0, rng); - return x; + sample_to(2.0, 10.0, rng); } }