You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"));
}
The text was updated successfully, but these errors were encountered:
Example from here: https://doc.rust-lang.org/std/fs/struct.File.html
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:
The text was updated successfully, but these errors were encountered: