Skip to content

Instantly share code, notes, and snippets.

@Geal
Created January 16, 2014 18:30
Show Gist options
  • Save Geal/8460511 to your computer and use it in GitHub Desktop.
Save Geal/8460511 to your computer and use it in GitHub Desktop.
Fun with mutable readers!
use std::io;
pub struct A<'a, R> {
reader: &'a R
}
pub fn init<'a, R: io::Reader>(r: &'a R) -> ~Parser<'a, R> {
~A {
reader: r
}
}
impl<'a, R: io::Reader> A<'a, R> {
fn get() {
let mut bytes = [0, .. 1024];
let optnbread = self.reader.read(bytes); // error: cannot borrow immutable dereference of & pointer as mutable
if optnbread.is_some() {
// blah blah blah
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment