aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-08-13 09:47:40 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-08-13 09:47:40 -0700
commit7ec4821bd7e78e425e9721b245e4a82bd46541a6 (patch)
treebddebf739d51da6f15db255eabd98ef27909c757
parentf011b0105189af7c131b257a210b5eb49c84ba1a (diff)
downloadmilf-rs-7ec4821bd7e78e425e9721b245e4a82bd46541a6.tar.gz
milf-rs-7ec4821bd7e78e425e9721b245e4a82bd46541a6.zip
Touch up some style in the decoder
-rw-r--r--src/decoder/serde.rs18
1 files changed, 12 insertions, 6 deletions
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::<DecodeError>;
- 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<D>(deserializer: &mut D) -> Result<Value, D::Error> where D: de::Deserializer {
+ fn deserialize<D>(deserializer: &mut D) -> Result<Value, D::Error>
+ 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<V>(&mut self, visitor: V) -> Result<Value, V::Error> where V: de::SeqVisitor {
+ fn visit_seq<V>(&mut self, visitor: V) -> Result<Value, V::Error>
+ where V: de::SeqVisitor
+ {
let values = try!(de::impls::VecVisitor::new().visit_seq(visitor));
Ok(Value::Array(values))
}
- fn visit_map<V>(&mut self, visitor: V) -> Result<Value, V::Error> where V: de::MapVisitor {
- let values = try!(de::impls::BTreeMapVisitor::new().visit_map(visitor));
+ fn visit_map<V>(&mut self, visitor: V) -> Result<Value, V::Error>
+ where V: de::MapVisitor
+ {
+ let mut v = de::impls::BTreeMapVisitor::new();
+ let values = try!(v.visit_map(visitor));
Ok(Value::Table(values))
}
}