diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-05-18 19:10:15 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-05-18 19:10:40 +0200 |
commit | bcf1a6c5e54b9f5892f622eb8bcb0fbe669b2794 (patch) | |
tree | 101ba3aca804ce917ce5130a225dd972c934cc0b /components | |
parent | 864f5509d8d82609b1be7c9571395fbefa84fa9e (diff) | |
download | servo-bcf1a6c5e54b9f5892f622eb8bcb0fbe669b2794.tar.gz servo-bcf1a6c5e54b9f5892f622eb8bcb0fbe669b2794.zip |
Avoid unwrap in LengthOrPercentageOrAuto::compute_squared_distance
Diffstat (limited to 'components')
-rw-r--r-- | components/style/properties/helpers/animated_properties.mako.rs | 10 |
1 files 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<CalcLengthOrPercentage> = From::from(this); let other: Option<CalcLengthOrPercentage> = 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(()) } } } |