Is it possible to do something like this? If not?
#![feature(conservative_impl_trait)]
use std::error::Error;
use std::io::{self, Read};
fn main() {
if let Err(e) = foo() {
println!("Error: {}", e);
}
}
fn foo() -> Result<(), impl Error> {
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer)?;
let _: i32 = buffer.parse()?;
Ok(())
}
I get this error:
error[E0282]: type annotations needed
--> result.rs:12:24
|
12 | fn foo() -> Result<(), impl Error> {
| ^^^^^^^^^^ cannot infer type for `_`
source
share