From 7ec4821bd7e78e425e9721b245e4a82bd46541a6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 13 Aug 2015 09:47:40 -0700 Subject: Touch up some style in the decoder --- src/decoder/serde.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/serde.rs b/src/decoder/serde.rs index 90738d1..47221b6 100644 --- a/src/decoder/serde.rs +++ b/src/decoder/serde.rs @@ -179,7 +179,7 @@ impl de::Deserializer for Decoder { // most likely being written down without losing too much info. let mut first_error = None::; - for variant in 0 .. variants.len() { + for variant in 0..variants.len() { let mut de = VariantVisitor { de: self.sub_decoder(self.toml.clone(), ""), variant: variant, @@ -461,9 +461,10 @@ impl de::Deserializer for UnitDeserializer { } } -// Based on https://github.com/serde-rs/serde/blob/199ed417bd6afc2071d17759b8c7e0ab8d0ba4cc/serde_json/src/value.rs#L265 impl de::Deserialize for Value { - fn deserialize(deserializer: &mut D) -> Result where D: de::Deserializer { + fn deserialize(deserializer: &mut D) -> Result + where D: de::Deserializer + { struct ValueVisitor; impl de::Visitor for ValueVisitor { @@ -489,13 +490,18 @@ impl de::Deserialize for Value { Ok(Value::String(value)) } - fn visit_seq(&mut self, visitor: V) -> Result where V: de::SeqVisitor { + fn visit_seq(&mut self, visitor: V) -> Result + where V: de::SeqVisitor + { let values = try!(de::impls::VecVisitor::new().visit_seq(visitor)); Ok(Value::Array(values)) } - fn visit_map(&mut self, visitor: V) -> Result where V: de::MapVisitor { - let values = try!(de::impls::BTreeMapVisitor::new().visit_map(visitor)); + fn visit_map(&mut self, visitor: V) -> Result + where V: de::MapVisitor + { + let mut v = de::impls::BTreeMapVisitor::new(); + let values = try!(v.visit_map(visitor)); Ok(Value::Table(values)) } } -- cgit v1.2.3