Move impl's into macro for macro-generated keyword types

Three keyword types are created through a macro but have some of their
impl's handled elsewhere. Since all impl's are the same, this commit
moves them into the macro to have them auto generated, for more concise
code.
This commit is contained in:
Aaron Cunningham 2017-04-26 12:38:21 -07:00
parent 18c72ac28d
commit f6d09a39f8
2 changed files with 17 additions and 52 deletions

View file

@ -11,6 +11,7 @@
use Atom;
pub use cssparser::{RGBA, Token, Parser, serialize_identifier, serialize_string};
use parser::{Parse, ParserContext};
use properties::animated_properties::{ComputeDistance, Interpolate};
use std::ascii::AsciiExt;
use std::borrow::Cow;
use std::fmt::{self, Debug};
@ -126,6 +127,20 @@ macro_rules! define_keyword_type {
}
}
impl Interpolate for $name {
#[inline]
fn interpolate(&self, _other: &Self, _progress: f64) -> Result<Self, ()> {
Ok($name)
}
}
impl ComputeDistance for $name {
#[inline]
fn compute_distance(&self, _other: &Self) -> Result<f64, ()> {
Err(())
}
}
impl fmt::Debug for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, $css)