Closed
Description
Given the following code: playground
fn main() {
let x: i32 = 1;
println!("{:?}", x.count())
}
The current output is:
error[E0599]: the method `count` exists for type `i32`, but its trait bounds were not satisfied
--> src/main.rs:3:24
|
3 | println!("{:?}", x.count())
| ^^^^^ method cannot be called on `i32` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`i32: Iterator`
which is required by `&mut i32: Iterator`
error: aborting due to previous error
Ideally the output should look like:
error[E0599]: the method `count` does not exist for type `i32`
For some reason, this doesn't happen for all traits in std
. Eg
fn main() {
let x: i32 = 1;
println!("{:?}", x.write(&[1, 2, 3]))
}
Just gives
error[E0599]: no method named `write` found for type `i32` in the current scope
--> src/main.rs:3:24
|
3 | println!("{:?}", x.write(&[1, 2, 3]))
| ^^^^^ method not found in `i32`
error: aborting due to previous error
Version: 1.53.0-nightly (2021-04-22 7f4afdf)