diff --git a/instant-xml/src/impls.rs b/instant-xml/src/impls.rs index 40d7c36..272185e 100644 --- a/instant-xml/src/impls.rs +++ b/instant-xml/src/impls.rs @@ -144,13 +144,11 @@ macro_rules! from_xml_for_number { let mut value = None; FromXmlStr::::deserialize(deserializer, &mut value)?; - match value { - Some(value) => { - *into = Some(value.0); - Ok(()) - } - None => Err(Error::MissingValue(Kind::Scalar)), + if let Some(value) = value { + *into = Some(value.0); } + + Ok(()) } const KIND: Kind = Kind::Scalar; @@ -190,13 +188,11 @@ impl<'xml> FromXml<'xml> for char { let mut value = None; FromXmlStr::::deserialize(deserializer, &mut value)?; - match value { - Some(value) => { - *into = Some(value.0); - Ok(()) - } - None => Err(Error::MissingValue(Kind::Scalar)), + if let Some(value) = value { + *into = Some(value.0); } + + Ok(()) } const KIND: Kind = Kind::Scalar; @@ -283,13 +279,11 @@ where let mut value = None; T::Owned::deserialize(deserializer, &mut value)?; - match value { - Some(value) => { - *into = Some(Cow::Owned(value)); - Ok(()) - } - None => Err(Error::MissingValue(Kind::Scalar)), + if let Some(value) = value { + *into = Some(Cow::Owned(value)); } + + Ok(()) } const KIND: Kind = Kind::Scalar; @@ -308,23 +302,17 @@ impl<'xml, T: FromXml<'xml>> FromXml<'xml> for Option { match into.as_mut() { Some(value) => { ::deserialize(deserializer, value)?; - match value { - Some(_) => Ok(()), - None => Err(Error::MissingValue(>::KIND)), - } } None => { let mut value = None; ::deserialize(deserializer, &mut value)?; - match value { - Some(value) => { - *into = Some(Some(value)); - Ok(()) - } - None => Err(Error::MissingValue(>::KIND)), + if let Some(value) = value { + *into = Some(Some(value)); } } } + + Ok(()) } fn missing_value() -> Result { @@ -709,13 +697,11 @@ impl<'xml> FromXml<'xml> for IpAddr { let mut value = None; FromXmlStr::::deserialize(deserializer, &mut value)?; - match value { - Some(value) => { - *into = Some(value.0); - Ok(()) - } - None => Err(Error::MissingValue(Kind::Scalar)), + if let Some(value) = value { + *into = Some(value.0); } + + Ok(()) } const KIND: Kind = Kind::Scalar;