What's the most idiomatic way to dereference while iterating?

109 points thomastc

Assume we have some container of values that implement Copy, we need to iterate over these by value, and we don't want to consume the container:

let v = vec![1, 2, 3, 4, 5];

Option 1:

for item in v.iter() {
    // Use *item
}

Option 2:

for &item in v.iter() {
    // Use item
}

Option 3:

for item in v.iter().copied() {
    // Use item
}

I keep finding myself pingponging between all these options. Is one of them considered more idiomatic or more preferred for some reason? Or is it only a matter of taste?