style: Use derive for -x-span.

This commit is contained in:
Emilio Cobos Álvarez 2017-09-09 13:18:50 +02:00
parent 156b371376
commit b9f5388635
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 24 additions and 17 deletions

View file

@ -4,6 +4,24 @@
//! Various macro helpers.
macro_rules! trivial_to_computed_value {
($name: ident) => {
impl $crate::values::computed::ToComputedValue for $name {
type ComputedValue = $name;
fn to_computed_value(&self, _: &$crate::values::computed::Context) -> Self {
self.clone()
}
fn from_computed_value(other: &Self) -> Self {
other.clone()
}
}
}
}
trivial_to_computed_value!(i32);
/// A macro to parse an identifier, or return an `UnexpectedIndent` error
/// otherwise.
///
@ -76,17 +94,7 @@ macro_rules! add_impls_for_keyword_enum {
}
}
impl $crate::values::computed::ToComputedValue for $name {
type ComputedValue = $name;
fn to_computed_value(&self, _: &$crate::values::computed::Context) -> Self {
self.clone()
}
fn from_computed_value(other: &Self) -> Self {
other.clone()
}
}
trivial_to_computed_value!($name);
};
}