Remove visit_usize and visit_bytes for Duration impl

This commit is contained in:
David Tolnay
2017-01-17 23:25:56 -08:00
parent aa88f01cdc
commit 984ebcead0
-23
View File
@@ -977,16 +977,6 @@ impl Deserialize for Duration {
impl Visitor for FieldVisitor {
type Value = Field;
fn visit_usize<E>(self, value: usize) -> Result<Field, E>
where E: Error,
{
match value {
0usize => Ok(Field::Secs),
1usize => Ok(Field::Nanos),
_ => Err(Error::invalid_value("expected a field")),
}
}
fn visit_str<E>(self, value: &str) -> Result<Field, E>
where E: Error,
{
@@ -996,19 +986,6 @@ 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)