What Is the Difference Between (&V). Func() and &V. Func()?
What Is (&V) Actually Doing in This Code? Let v = Vec! ["Hello", "Viktor"]; Let Mut Iterator = (&V). Into_Iter(); // Iter Let Mut Iterator = &V. Into_Iter()...
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.