Touch up some style in the decoder
This commit is contained in:
parent
f011b01051
commit
7ec4821bd7
|
@ -179,7 +179,7 @@ impl de::Deserializer for Decoder {
|
||||||
// most likely being written down without losing too much info.
|
// most likely being written down without losing too much info.
|
||||||
let mut first_error = None::<DecodeError>;
|
let mut first_error = None::<DecodeError>;
|
||||||
|
|
||||||
for variant in 0 .. variants.len() {
|
for variant in 0..variants.len() {
|
||||||
let mut de = VariantVisitor {
|
let mut de = VariantVisitor {
|
||||||
de: self.sub_decoder(self.toml.clone(), ""),
|
de: self.sub_decoder(self.toml.clone(), ""),
|
||||||
variant: variant,
|
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 {
|
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;
|
struct ValueVisitor;
|
||||||
|
|
||||||
impl de::Visitor for ValueVisitor {
|
impl de::Visitor for ValueVisitor {
|
||||||
|
@ -489,13 +490,18 @@ impl de::Deserialize for Value {
|
||||||
Ok(Value::String(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));
|
let values = try!(de::impls::VecVisitor::new().visit_seq(visitor));
|
||||||
Ok(Value::Array(values))
|
Ok(Value::Array(values))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_map<V>(&mut self, visitor: V) -> Result<Value, V::Error> where V: de::MapVisitor {
|
fn visit_map<V>(&mut self, visitor: V) -> Result<Value, V::Error>
|
||||||
let values = try!(de::impls::BTreeMapVisitor::new().visit_map(visitor));
|
where V: de::MapVisitor
|
||||||
|
{
|
||||||
|
let mut v = de::impls::BTreeMapVisitor::new();
|
||||||
|
let values = try!(v.visit_map(visitor));
|
||||||
Ok(Value::Table(values))
|
Ok(Value::Table(values))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue