From 83ee86122b59703ae777ca61eb1a82dcfb374ffa Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 8 May 2015 16:32:46 +0200 Subject: [PATCH] address comments by erickt --- src/de/impls.rs | 36 ++---------------------------------- src/iter.rs | 12 +++++++----- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/src/de/impls.rs b/src/de/impls.rs index ac340115..9fde989b 100644 --- a/src/de/impls.rs +++ b/src/de/impls.rs @@ -93,10 +93,6 @@ macro_rules! impl_deserialize_num_method { } } -pub struct NumericVisitor { - marker: PhantomData, -} - pub struct PrimitiveVisitor { marker: PhantomData, } @@ -110,18 +106,9 @@ impl PrimitiveVisitor { } } -impl NumericVisitor { - #[inline] - pub fn new() -> Self { - NumericVisitor { - marker: PhantomData, - } - } -} - impl< T: Deserialize + FromPrimitive + str::FromStr -> Visitor for NumericVisitor { +> Visitor for PrimitiveVisitor { type Value = T; impl_deserialize_num_method!(isize, visit_isize, from_isize); @@ -145,25 +132,6 @@ impl< } } -impl< - T: Deserialize + FromPrimitive -> Visitor for PrimitiveVisitor { - type Value = T; - - impl_deserialize_num_method!(isize, visit_isize, from_isize); - impl_deserialize_num_method!(i8, visit_i8, from_i8); - impl_deserialize_num_method!(i16, visit_i16, from_i16); - impl_deserialize_num_method!(i32, visit_i32, from_i32); - impl_deserialize_num_method!(i64, visit_i64, from_i64); - impl_deserialize_num_method!(usize, visit_usize, from_usize); - impl_deserialize_num_method!(u8, visit_u8, from_u8); - impl_deserialize_num_method!(u16, visit_u16, from_u16); - impl_deserialize_num_method!(u32, visit_u32, from_u32); - impl_deserialize_num_method!(u64, visit_u64, from_u64); - impl_deserialize_num_method!(f32, visit_f32, from_f32); - impl_deserialize_num_method!(f64, visit_f64, from_f64); -} - macro_rules! impl_deserialize_num { ($ty:ty) => { impl Deserialize for $ty { @@ -171,7 +139,7 @@ macro_rules! impl_deserialize_num { fn deserialize(deserializer: &mut D) -> Result<$ty, D::Error> where D: Deserializer, { - deserializer.visit(NumericVisitor::new()) + deserializer.visit(PrimitiveVisitor::new()) } } } diff --git a/src/iter.rs b/src/iter.rs index ddcfbb79..ec0bb134 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -2,7 +2,7 @@ use std::io; use std::iter::Peekable; pub struct LineColIterator>> { - iter: Peekable, + iter: Iter, line: usize, col: usize, } @@ -10,7 +10,7 @@ pub struct LineColIterator>> { impl>> LineColIterator { pub fn new(iter: Iter) -> LineColIterator { LineColIterator { - iter: iter.peekable(), + iter: iter, line: 1, col: 0, } @@ -23,14 +23,16 @@ impl>> LineColIterator { pub fn col(&self) -> usize { self.col } /// Gets a reference to the underlying iterator. - pub fn get_ref(&self) -> &Peekable { &self.iter } + pub fn get_ref(&self) -> &Iter { &self.iter } /// Gets a mutable reference to the underlying iterator. - pub fn get_mut(&mut self) -> &mut Peekable { &mut self.iter } + pub fn get_mut(&mut self) -> &mut Iter { &mut self.iter } /// Unwraps this `LineColIterator`, returning the underlying iterator. - pub fn into_inner(self) -> Peekable { self.iter } + pub fn into_inner(self) -> Iter { self.iter } +} +impl>> LineColIterator> { /// peeks at the next value pub fn peek(&mut self) -> Option<&io::Result> { self.iter.peek() } }