Why not iterators? `for x in rgradients.mut_iter() { *x = random_gradient(&mut rng); }`