Created
July 30, 2014 16:23
-
-
Save jroesch/c94e7a005846f790e3b5 to your computer and use it in GitHub Desktop.
bug.rs
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::io::BufferedReader; | |
use std::io::File; | |
pub struct Data { | |
content: Box<Iterator<String>> | |
} | |
impl Iterator<String> for Data { | |
fn next(&mut self) -> Option<String> { | |
self.content.next() | |
} | |
} | |
fn new_data(file_name: &str) -> Data { | |
let path = Path::new(file_name); | |
let file = File::open(&path); | |
let mut reader = BufferedReader::new(file); | |
Data { content: box reader.lines().map(|str| str.unwrap()) } | |
} | |
fn main() { | |
let mut data = new_data("prelude.ob"); | |
println!("{}", data.next()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using
rustc 0.12.0-pre-nightly (5ebf4813a 2014-07-29 21:16:50 +0000)