From bcf1a6c5e54b9f5892f622eb8bcb0fbe669b2794 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 18 May 2017 19:10:15 +0200 Subject: [PATCH] Avoid unwrap in LengthOrPercentageOrAuto::compute_squared_distance --- .../properties/helpers/animated_properties.mako.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 0fffb440d01..85f8ec9281f 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -1185,12 +1185,12 @@ impl Animatable for LengthOrPercentageOrAuto { (this, other) => { let this: Option = From::from(this); let other: Option = From::from(other); - if this.is_none() || other.is_none() { - Err(()) - } else { - let length_diff = (this.unwrap().length().0 - other.unwrap().length().0) as f64; - let percentage_diff = (this.unwrap().percentage() - other.unwrap().percentage()) as f64; + if let (Some(this), Some(other)) = (this, other) { + let length_diff = (this.length().0 - other.length().0) as f64; + let percentage_diff = (this.percentage() - other.percentage()) as f64; Ok(length_diff * length_diff + percentage_diff * percentage_diff) + } else { + Err(()) } } }