style: Be a little less From-happy with rect.

This commit is contained in:
Emilio Cobos Álvarez 2017-09-16 17:29:43 +02:00
parent 7e4338eed8
commit 7a265793c8
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 13 additions and 15 deletions

View file

@ -217,8 +217,8 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
parse_method="parse_non_negative",
initial_value="computed::LengthOrNumber::zero().into()",
initial_specified_value="specified::LengthOrNumber::zero().into()",
initial_value="computed::LengthOrNumberRect::all(computed::LengthOrNumber::zero())",
initial_specified_value="specified::LengthOrNumberRect::all(specified::LengthOrNumber::zero())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset",
animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER",
@ -284,8 +284,8 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
</%helpers:longhand>
${helpers.predefined_type("border-image-width", "BorderImageWidth",
initial_value="computed::BorderImageSideWidth::one().into()",
initial_specified_value="specified::BorderImageSideWidth::one().into()",
initial_value="computed::BorderImageWidth::all(computed::BorderImageSideWidth::one())",
initial_specified_value="specified::BorderImageWidth::all(specified::BorderImageSideWidth::one())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-width",
animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER",

View file

@ -85,7 +85,7 @@ impl<N> From<N> for BorderImageSlice<N>
#[inline]
fn from(value: N) -> Self {
Self {
offsets: value.into(),
offsets: Rect::all(value),
fill: false,
}
}

View file

@ -27,6 +27,11 @@ impl<T> Rect<T> {
impl<T> Rect<T>
where T: Clone
{
/// Returns a rect with all the values equal to `v`.
pub fn all(v: T) -> Self {
Rect::new(v.clone(), v.clone(), v.clone(), v)
}
/// Parses a new `Rect<T>` value with the given parse function.
pub fn parse_with<'i, 't, Parse>(
context: &ParserContext,
@ -53,15 +58,6 @@ impl<T> Rect<T>
}
}
impl<T> From<T> for Rect<T>
where T: Clone
{
#[inline]
fn from(value: T) -> Self {
Self::new(value.clone(), value.clone(), value.clone(), value)
}
}
impl<T> Parse for Rect<T>
where T: Clone + Parse
{