core: Add iterable functions to io::reader_utils.

This commit is contained in:
Erick Tryzelaar 2012-05-01 08:14:56 -07:00
parent e7ca3e4db0
commit 9d01c46c07

View File

@ -161,6 +161,24 @@ fn read_whole_stream() -> [u8] {
while !self.eof() { buf += self.read_bytes(2048u); }
buf
}
fn each_byte(it: fn(int) -> bool) {
while !self.eof() {
if !it(self.read_byte()) { break; }
}
}
fn each_char(it: fn(char) -> bool) {
while !self.eof() {
if !it(self.read_char()) { break; }
}
}
fn each_line(it: fn(str) -> bool) {
while !self.eof() {
if !it(self.read_line()) { break; }
}
}
}
// Reader implementations