Created
January 28, 2015 00:47
-
-
Save wagenet/790acd3a0f07b97d5410 to your computer and use it in GitHub Desktop.
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
16:22 error: cannot assign to immutable field `self.pos` | |
self.pos += 1; | |
^~~~~~~~~~~~~ |
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
pub struct BindIter<'a> { | |
binds: &'a [String], | |
pos: uint, | |
} | |
impl<'a> Iterator for &'a BindIter<'a> { | |
type Item = &'a str; | |
fn next(&mut self) -> Option<&'a str> { | |
let pos = self.pos; | |
if pos == self.binds.len() { | |
return None; | |
} | |
self.pos += 1; | |
Some(self.binds[pos].as_slice()) | |
} | |
fn size_hint(&self) -> (uint, Option<uint>) { | |
let ret = self.binds.len() - self.pos; | |
(ret, Some(ret)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment