Use match guard clause (preparation for adding more logic)
@@ -44,7 +44,11 @@ impl TryConvertMut<Option<Value>, SubsecMultiplier> for Artichoke {
type Error = Error;
fn try_convert_mut(&mut self, subsec_type: Option<Value>) -> Result<SubsecMultiplier, Self::Error> {
- if let Some(mut subsec_type) = subsec_type {
+ let mut subsec_type = match subsec_type {
+ Some(t) => t,
+ None => return Ok(SubsecMultiplier::Micros),
+ };
+
let subsec_symbol = unsafe { Symbol::unbox_from_value(&mut subsec_type, self)? }.bytes(self);
match subsec_symbol {
b"milliseconds" => Ok(SubsecMultiplier::Millis),
@@ -56,9 +60,6 @@ impl TryConvertMut<Option<Value>, SubsecMultiplier> for Artichoke {
Err(ArgumentError::from(message).into())
}
}
- } else {
- Ok(SubsecMultiplier::Micros)
- }
}
}
