Skip to content

Instantly share code, notes, and snippets.

@AleksLitynski
Last active December 20, 2015 05:09
Show Gist options
  • Save AleksLitynski/6076352 to your computer and use it in GitHub Desktop.
Save AleksLitynski/6076352 to your computer and use it in GitHub Desktop.
file IO error
let file_read: Result<@Reader, ~str> = std::io::file_reader(~std::path::Path("handw.rc"));
let file_text:~[~str] = match file_read {
Ok(file) => return file.read_lines(),
Err(e) => {
println(fmt!("Error reading file: %?", e));
return ~[];
}
};
extern mod std;
use std::io::*;
use std::path::*;
fn main(){
let rdr = file_reader(~PosixPath("testing.rs"));
let r = rdr;
let readText = match r {
Ok(file) => {file.read_lines()}
Err(e) => {~[]}
};
println( fmt!("%?", readText) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment