2 ms·
You are right. The parameter given to the closure is the array index, which is usize. Since that's returned straight back the returned value is also of type usi
by wongarsu 4y ago
You are right. The parameter given to the closure is the array index, which is usize. Since that's returned straight back the returned value is also of type usize, and the integers in the array in the assert are inferred to also be usize.
Which is in a way an even stronger showcase of Rust's type inference: the length of the variable is inferred from the constant array, but the type of the content of the constant array is inferred by the type of the content of the variable, which is inferred from the type of the closure.