K
is an i64
and points
is a Vec<Vec<i64>>
that is used to represent points in an n-dim space.
let mut centroids: Vec<Vec<i64>> =
rand::seq::sample_iter(&mut rand::thread_rng(),
points.iter(),
K as usize).unwrap();
Is rand::thread_rng()
moved into the function scope and thus gotten rid of at the end of the function? (making the whole thing not leak memory)
If not, is there a way to do so without declaring it separately? What led me to this question is the way the drop
function works since it pretty much employs the same idea.