Created
December 10, 2013 17:11
-
-
Save Geal/7894264 to your computer and use it in GitHub Desktop.
Rust file usage
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::rt::io::File; | |
use std::rt::io::buffered::BufferedReader; | |
[...] | |
let s:~str = ~"file.txt"; | |
let mut strings:~[~str] = ~[]; | |
let path = PosixPath::new(s); | |
let mut rdr = BufferedReader::new(File::open(&path).unwrap()); | |
loop { | |
match rdr.read_line() { | |
Some(line) => strings.push(line), | |
None => break | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment