Closed
Description
try! isn't directly usable in main, because it returns IoResult.
extern mod std;
use std::io::IoResult;
fn something() -> IoResult<bool> {
Ok(true)
}
fn main() {
let a = try!(something());
println!("{}", a);
}
fails with
<std macros>:2:59: 2:65 error: mismatched types: expected `()` but found `std::result::Result<<generic #15>,std::io::IoError>` (expected () but found enum std::result::Result)
<std macros>:2 ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
^~~~~~
<std macros>:1:1: 3:2 note: in expansion of if_ok!
if_ok_main.rs:10:13: 10:33 note: expansion site
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
No labels