Skip to content

Instantly share code, notes, and snippets.

@dbrgn
Last active December 29, 2015 09:12
Show Gist options
  • Select an option

  • Save dbrgn/fd31964624bbf4942a14 to your computer and use it in GitHub Desktop.

Select an option

Save dbrgn/fd31964624bbf4942a14 to your computer and use it in GitHub Desktop.
struct Tokenizer<R: BufRead> {
reader: R,
current_line: String,
}
impl<R> Iterator for Tokenizer<R> where R: BufRead {
type Item = &'a str;
fn next<'a>(&'a mut self) -> Option<&'a str> {
self.current_line.clear();
let bytes_read = self.reader.read_line(&mut self.current_line).unwrap();
match bytes_read {
0 => None,
_ => Some(&self.current_line),
}
}
}
src/main.rs:37:18: 37:20 error: use of undeclared lifetime name `'a` [E0261]
src/main.rs:37 type Item = &'a str;
^~
src/main.rs:37:18: 37:20 help: run `rustc --explain E0261` to see a detailed explanation
error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment