style: Use style::One for Integer to avoid implementing Mul.

Differential Revision: https://phabricator.services.mozilla.com/D76207
This commit is contained in:
Boris Chiou 2020-05-20 21:13:37 +00:00 committed by Emilio Cobos Álvarez
parent 7022f451e1
commit 35546aea54
2 changed files with 6 additions and 10 deletions

View file

@ -5,9 +5,9 @@
//! Generic types for font stuff. //! Generic types for font stuff.
use crate::parser::{Parse, ParserContext}; use crate::parser::{Parse, ParserContext};
use crate::One;
use byteorder::{BigEndian, ReadBytesExt}; use byteorder::{BigEndian, ReadBytesExt};
use cssparser::Parser; use cssparser::Parser;
use num_traits::One;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use std::io::Cursor; use std::io::Cursor;
use style_traits::{CssWriter, ParseError}; use style_traits::{CssWriter, ParseError};
@ -42,7 +42,7 @@ where
{ {
self.tag.to_css(dest)?; self.tag.to_css(dest)?;
// Don't serialize the default value. // Don't serialize the default value.
if self.value != Integer::one() { if !self.value.is_one() {
dest.write_char(' ')?; dest.write_char(' ')?;
self.value.to_css(dest)?; self.value.to_css(dest)?;
} }

View file

@ -555,19 +555,15 @@ impl Zero for Integer {
} }
} }
impl num_traits::One for Integer { impl One for Integer {
#[inline] #[inline]
fn one() -> Self { fn one() -> Self {
Self::new(1) Self::new(1)
} }
}
// This is not great, because it loses calc-ness, but it's necessary for One. #[inline]
impl ::std::ops::Mul<Integer> for Integer { fn is_one(&self) -> bool {
type Output = Self; self.value() == 1
fn mul(self, other: Self) -> Self {
Self::new(self.value * other.value)
} }
} }