Created
May 26, 2015 11:48
-
-
Save b4284/7808616c40fd54acc9a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
use std::io::Read; | |
use std::string::String; | |
pub fn file_io_test(p: &str) { | |
let mut m = File::open(p).unwrap(); | |
let ref mut buf = [0; 256]; | |
let n = m.read(buf).unwrap(); | |
let c = String::from_utf8_lossy(buf); | |
let s = c.into_owned(); | |
println!("{} bytes read, printing them below:", n); | |
println!("{}", s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment