use std::io; pub struct LineColIterator>> { rdr: Iter, line: usize, col: usize, } impl>> LineColIterator { pub fn new(iter: Iter) -> LineColIterator { LineColIterator { line: 1, col: 0, rdr: iter, } } pub fn line(&self) -> usize { self.line } pub fn col(&self) -> usize { self.col } } impl>> Iterator for LineColIterator { type Item = io::Result; fn next(&mut self) -> Option> { match self.rdr.next() { None => None, Some(Ok(b'\n')) => { self.line += 1; self.col = 0; Some(Ok(b'\n')) }, Some(Ok(c)) => { self.col += 1; Some(Ok(c)) }, Some(Err(e)) => Some(Err(e)), } } }