mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Avoid unwrap in LengthOrPercentageOrAuto::compute_squared_distance
This commit is contained in:
parent
864f5509d8
commit
bcf1a6c5e5
1 changed files with 5 additions and 5 deletions
|
@ -1185,12 +1185,12 @@ impl Animatable for LengthOrPercentageOrAuto {
|
||||||
(this, other) => {
|
(this, other) => {
|
||||||
let this: Option<CalcLengthOrPercentage> = From::from(this);
|
let this: Option<CalcLengthOrPercentage> = From::from(this);
|
||||||
let other: Option<CalcLengthOrPercentage> = From::from(other);
|
let other: Option<CalcLengthOrPercentage> = From::from(other);
|
||||||
if this.is_none() || other.is_none() {
|
if let (Some(this), Some(other)) = (this, other) {
|
||||||
Err(())
|
let length_diff = (this.length().0 - other.length().0) as f64;
|
||||||
} else {
|
let percentage_diff = (this.percentage() - other.percentage()) as f64;
|
||||||
let length_diff = (this.unwrap().length().0 - other.unwrap().length().0) as f64;
|
|
||||||
let percentage_diff = (this.unwrap().percentage() - other.unwrap().percentage()) as f64;
|
|
||||||
Ok(length_diff * length_diff + percentage_diff * percentage_diff)
|
Ok(length_diff * length_diff + percentage_diff * percentage_diff)
|
||||||
|
} else {
|
||||||
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue