Created
January 16, 2014 18:30
-
-
Save Geal/8460511 to your computer and use it in GitHub Desktop.
Fun with mutable readers!
This file contains hidden or 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; | |
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