style: Derive more.

Differential Revision: https://phabricator.services.mozilla.com/D17029
This commit is contained in:
Bobby Holley 2019-01-18 12:39:29 -08:00 committed by Emilio Cobos Álvarez
parent 137e735d9d
commit af1bbd7b06
8 changed files with 14 additions and 91 deletions

View file

@ -9,13 +9,12 @@ use crate::values::CSSFloat;
use num_traits::Zero;
use std::f64::consts::PI;
use std::fmt::{self, Write};
use std::ops::Add;
use std::{f32, f64};
use style_traits::{CssWriter, ToCss};
/// A computed angle in degrees.
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToAnimatedZero)]
#[derive(Add, Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToAnimatedZero)]
pub struct Angle(CSSFloat);
impl ToCss for Angle {
@ -66,15 +65,6 @@ impl Angle {
}
}
impl Add for Angle {
type Output = Self;
#[inline]
fn add(self, rhs: Self) -> Self {
Angle(self.0 + rhs.0)
}
}
impl Zero for Angle {
#[inline]
fn zero() -> Self {

View file

@ -31,7 +31,7 @@ pub trait ComputeSquaredDistance {
}
/// A distance between two animatable values.
#[derive(Clone, Copy, Debug)]
#[derive(Add, Clone, Copy, Debug, From)]
pub struct SquaredDistance {
value: f64,
}
@ -114,24 +114,6 @@ impl SquaredDistance {
}
}
impl From<SquaredDistance> for f64 {
#[inline]
fn from(distance: SquaredDistance) -> Self {
distance.value
}
}
impl Add for SquaredDistance {
type Output = Self;
#[inline]
fn add(self, rhs: Self) -> Self {
SquaredDistance {
value: self.value + rhs.value,
}
}
}
impl Sum for SquaredDistance {
fn sum<I>(iter: I) -> Self
where

View file

@ -11,7 +11,6 @@ use crate::values::CSSFloat;
use cssparser::Parser;
use std::fmt::{self, Write};
use std::iter::{Cloned, Peekable};
use std::ops::AddAssign;
use std::slice;
use style_traits::values::SequenceWriter;
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
@ -491,6 +490,7 @@ impl IsAbsolute {
/// The path coord type.
#[derive(
AddAssign,
Animate,
Clone,
ComputeSquaredDistance,
@ -513,14 +513,6 @@ impl CoordPair {
}
}
impl AddAssign for CoordPair {
#[inline]
fn add_assign(&mut self, other: Self) {
self.0 += other.0;
self.1 += other.1;
}
}
/// The EllipticalArc flag type.
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo)]
#[repr(C)]