Can someone enlighten me as to why the first snippet has a data race? Won't the resulting array become [2,3,4]?
let mut data = vec![1, 2, 3];
for i in 0..3 {
thread::spawn(move || {
data[i] += 1;
});
}