From this topic, I guess Vec<i32>.into_iter()
would return i32
type.
https://doc.rustlang.org/std/iter/index.html#thethreeformsofiteration

iter()
, which iterates over&T
. 
iter_mut()
, which iterates over&mut T
. 
into_iter()
, which iterates overT
.
But as following, I find that into_iter()
depend on the context , and iter()
, iter_mut()
work fine.
https://play.rustlang.org/?version=stable&mode=debug&edition=2018&gist=a0ae390e8dca9d5b8183842c82194210
fn into_iter_mut(v: &mut Vec<i32>) {
for i in v.into_iter(){
// expected `i32`, found `&mut i32`
let a:i32 = i;
}
for i in v.iter(){
// expected `i32`, found `&i32`
let a:i32 = i;
}
for i in v.iter_mut(){
// expected `i32`, found `&mut i32`
let a:i32 = i;
}
}
fn into_iter_ref(v: &Vec<i32>) {
for i in v.into_iter(){
// expected `i32`, found `&i32`
let a:i32 = i;
}
for i in v.iter(){
// expected `i32`, found `&i32`
let a:i32 = i;
}
for i in v.iter_mut(){
// expected `i32`, found `&mut i32`
let a:i32 = i;
}
}
fn into_iter(v: Vec<i32>) {
for i in v.into_iter(){
// expected `i32`, found `i32`
let a:i32 = i;
}
for i in v.iter(){
// expected `i32`, found `&i32`
let a:i32 = i;
}
for i in v.iter_mut(){
// expected `i32`, found `&mut i32`
let a:i32 = i;
}
}
fn main() {}