Open
Description
use std::num::ParseIntError;
fn run() -> Result<(), ParseIntError> {
let v = vec![1,2,3];
let x = "1".parse()?;
println!("{:?}", v[x]);
Ok(())
}
fn main() {
let _ = run();
}
has the confusing error message
error[E0277]: the trait bound `(): std::str::FromStr` is not satisfied
--> <anon>:6:17
|
6 | let x = "1".parse()?;
| ^^^^^ the trait `std::str::FromStr` is not implemented for `()`
error[E0277]: the trait bound `std::vec::Vec<i32>: std::ops::Index<()>` is not satisfied
--> <anon>:8:22
|
8 | println!("{:?}", v[x]);
| ^^^^ the trait `std::ops::Index<()>` is not implemented for `std::vec::Vec<i32>`
|
= note: the type `std::vec::Vec<i32>` cannot be indexed by `()`
replacing the ?
with .unwrap()
gives a nicer explanation of the problem (try!
gives the same error message as ?
)
error[E0282]: unable to infer enough type information about `_`
--> <anon>:6:9
|
6 | let x = "1".parse().unwrap();
| ^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required