Closed
Description
Example from here: https://doc.rust-lang.org/std/fs/struct.File.html
use std::io::prelude::*;
use std::fs::File;
let mut f = try!(File::create("foo.txt"));
try!(f.write_all(b"Hello, world!"));
let mut f = try!(File::open("foo.txt"));
let mut s = String::new();
try!(f.read_to_string(&mut s));
assert_eq!(s, "Hello, world!");
Compiling results to: error: mismatched types [E0308]
Funny because when running rustc --explain E0308 it tells me not to use try! with File:
rustc --explain E0308:
Another situation in which this occurs is when you attempt to use the `try!`
macro inside a function that does not return a `Result<T, E>`:
use std::fs::File;
fn main() {
let mut f = try!(File::create("foo.txt"));
}
Metadata
Metadata
Assignees
Labels
No labels