Closed
Description
Given the following code:
let arr = &[0,1,2,3];
for i in 0..arr.len().rev() {
// ...
}
The current output is:
error[E0599]: the method `rev` exists for type `usize`, but its trait bounds were not satisfied
--> src/main.rs:5:25
|
5 | for i in 0..arr.len().rev() {
| ^^^ method cannot be called on `usize` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`usize: Iterator`
which is required by `&mut usize: Iterator
Ideally the output should look like:
// Minimal fix: remove misleading message:
Omit "the method rev exists for type usize."
// Amazing fix:
|
5 | for i in 0..arr.len().rev() {
| ^^^ method cannot be called on `usize` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`usize: Iterator`
which is required by `&mut usize: Iterator
= hint: (0..arr.len()) implements `Iterator`, perhaps you are missing parentheses?