Restore visit_bytes for Duration impl

This commit is contained in:
David Tolnay 2017-01-18 21:13:51 -08:00
parent 984ebcead0
commit e40fbe0767
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -986,6 +986,19 @@ impl Deserialize for Duration {
_ => Err(Error::unknown_field(value)),
}
}
fn visit_bytes<E>(self, value: &[u8]) -> Result<Field, E>
where E: Error,
{
match value {
b"secs" => Ok(Field::Secs),
b"nanos" => Ok(Field::Nanos),
_ => {
let value = String::from_utf8_lossy(value);
Err(Error::unknown_field(&value))
}
}
}
}
deserializer.deserialize_struct_field(FieldVisitor)