Rename iterator.rs to iter.rs and expose it.

This commit is contained in:
Erick Tryzelaar 2015-04-26 09:02:34 -07:00
parent cf38b8dae5
commit eb9c860cb4
3 changed files with 9 additions and 8 deletions

View File

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

View File

@ -3,8 +3,9 @@ use std::io;
use std::str; use std::str;
use de; use de;
use iter::LineColIterator;
use super::error::{Error, ErrorCode}; use super::error::{Error, ErrorCode};
use iterator::LineColIterator;
pub struct Deserializer<Iter: Iterator<Item=io::Result<u8>>> { pub struct Deserializer<Iter: Iterator<Item=io::Result<u8>>> {
rdr: LineColIterator<Iter>, rdr: LineColIterator<Iter>,

View File

@ -12,8 +12,8 @@ extern crate num;
pub use ser::{Serialize, Serializer}; pub use ser::{Serialize, Serializer};
pub use de::{Deserialize, Deserializer, Error}; pub use de::{Deserialize, Deserializer, Error};
pub mod ser;
pub mod de;
pub mod json;
pub mod bytes; pub mod bytes;
mod iterator; pub mod de;
pub mod iter;
pub mod json;
pub mod ser;