Skip to content

Instantly share code, notes, and snippets.

@Geal
Created December 10, 2013 17:11
Show Gist options
  • Save Geal/7894264 to your computer and use it in GitHub Desktop.
Save Geal/7894264 to your computer and use it in GitHub Desktop.
Rust file usage
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