mercredi 18 octobre 2023

Why can I use `rng.gen()` but not `rng.gen_range()` when idiomatically initializing array with `core::array::from_fn()`?

In short: Why can I use

let array: [[f64; width]; length] = core::array::from_fn(|_| rng.gen());

but not

let array: [[f64; width]; length] = core::array::from_fn(|_| rng.gen_range(0.0..1.0));

It's not terribly that it doesn't work, but I don't understand the reason here.




Aucun commentaire:

Enregistrer un commentaire