Derive the most trivial ToAnimatedZero impls

This commit is contained in:
Anthony Ramine 2017-08-22 15:30:43 +02:00
parent 8ca9542de6
commit faaf31411a
15 changed files with 112 additions and 174 deletions

View file

@ -8,12 +8,12 @@ use std::{f32, f64, fmt};
use std::f64::consts::PI;
use style_traits::ToCss;
use values::CSSFloat;
use values::animated::{Animate, Procedure, ToAnimatedZero};
use values::animated::{Animate, Procedure};
use values::distance::{ComputeSquaredDistance, SquaredDistance};
/// A computed angle.
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, PartialOrd)]
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, PartialOrd, ToAnimatedZero)]
pub enum Angle {
/// An angle with degree unit.
Degree(CSSFloat),
@ -85,18 +85,6 @@ impl Animate for Angle {
}
}
impl ToAnimatedZero for Angle {
#[inline]
fn to_animated_zero(&self) -> Result<Angle, ()> {
match *self {
Angle::Degree(ref this) => Ok(Angle::Degree(this.to_animated_zero()?)),
Angle::Gradian(ref this) => Ok(Angle::Gradian(this.to_animated_zero()?)),
Angle::Radian(ref this) => Ok(Angle::Radian(this.to_animated_zero()?)),
Angle::Turn(ref this) => Ok(Angle::Turn(this.to_animated_zero()?)),
}
}
}
impl ComputeSquaredDistance for Angle {
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {