I have a Vec<f64> and I am trying to get say every 7th element of the vector till I run out of bounds, into another Vec<f64>. I thought maybe I could create an index of the elements I want and then filter based on that. But I can't seem to be able to do this directly or indirectly. What I tried
let x: Vec<f64> = (1..200)
.map(|x| (x as f64)/(200 as f64))
.collect();
let y: Vec<f64> = x
.enumerate()
.filter(|&(i, _)| i % 7 == 0 )
.map(|(_, e)| e)
.collect();
But this did not work with compile error enumerate method cannot be called on Vec<f64> due to unsatisfied trait bounds. I also found a retain method but don't see a way to apply it on the index rather than the element. A robust search of SO surprisingly did not yield anything.