What is (&v) actually doing in this code?
let v = vec!["hello", "viktor"]; let mut iterator = (&v).into_iter(); // Iter<&str> let mut iterator = &v.into_iter(); // &IntoIter<&str> How it is changing what is returned from .into_iter(). Why is the result different?
1 Answer
This is a precedence issue. With &v.into_iter(), the compiler understands &(v.into_iter()) not (&v).into_iter(), just like when you write 1+2*3, the compiler understands 1+(2*3), and not (1+2)*3.