Skip to content

Commit

Permalink
Derive ToComputedValue for Either<A, B>
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Jun 27, 2017
1 parent 79ee821 commit 6c17bb0
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions components/style/values/mod.rs
Expand Up @@ -52,7 +52,7 @@ impl Parse for Impossible {

/// A struct representing one of two kinds of values.
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, HasViewportPercentage, PartialEq, ToCss)]
#[derive(Clone, Copy, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
pub enum Either<A, B> {
/// The first value.
First(A),
Expand Down Expand Up @@ -80,27 +80,6 @@ impl<A: Parse, B: Parse> Parse for Either<A, B> {
}
}

use self::computed::{Context, ToComputedValue};

impl<A: ToComputedValue, B: ToComputedValue> ToComputedValue for Either<A, B> {
type ComputedValue = Either<A::ComputedValue, B::ComputedValue>;

fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
match *self {
Either::First(ref a) => Either::First(a.to_computed_value(context)),
Either::Second(ref a) => Either::Second(a.to_computed_value(context)),
}
}

#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
match *computed {
Either::First(ref a) => Either::First(ToComputedValue::from_computed_value(a)),
Either::Second(ref a) => Either::Second(ToComputedValue::from_computed_value(a)),
}
}
}

/// https://drafts.csswg.org/css-values-4/#custom-idents
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
Expand Down

0 comments on commit 6c17bb0

Please sign in to comment.