diff options
author | Boris Chiou <boris.chiou@gmail.com> | 2020-05-20 21:13:37 +0000 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-06-04 01:50:36 +0200 |
commit | 35546aea54e73ef1428d6921c0ec059a7250d526 (patch) | |
tree | 66d346795bbc58c5430cdcbeac5aba6dce0afe79 | |
parent | 7022f451e14c1cb09411bd1146da2816f6eac2c7 (diff) | |
download | servo-35546aea54e73ef1428d6921c0ec059a7250d526.tar.gz servo-35546aea54e73ef1428d6921c0ec059a7250d526.zip |
style: Use style::One for Integer to avoid implementing Mul.
Differential Revision: https://phabricator.services.mozilla.com/D76207
-rw-r--r-- | components/style/values/generics/font.rs | 4 | ||||
-rw-r--r-- | components/style/values/specified/mod.rs | 12 |
2 files changed, 6 insertions, 10 deletions
diff --git a/components/style/values/generics/font.rs b/components/style/values/generics/font.rs index 2b29104ff81..237e862d4aa 100644 --- a/components/style/values/generics/font.rs +++ b/components/style/values/generics/font.rs @@ -5,9 +5,9 @@ //! Generic types for font stuff. use crate::parser::{Parse, ParserContext}; +use crate::One; use byteorder::{BigEndian, ReadBytesExt}; use cssparser::Parser; -use num_traits::One; use std::fmt::{self, Write}; use std::io::Cursor; use style_traits::{CssWriter, ParseError}; @@ -42,7 +42,7 @@ where { self.tag.to_css(dest)?; // Don't serialize the default value. - if self.value != Integer::one() { + if !self.value.is_one() { dest.write_char(' ')?; self.value.to_css(dest)?; } diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index e9d25330f64..e45be0513a4 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -555,19 +555,15 @@ impl Zero for Integer { } } -impl num_traits::One for Integer { +impl One for Integer { #[inline] fn one() -> Self { Self::new(1) } -} - -// This is not great, because it loses calc-ness, but it's necessary for One. -impl ::std::ops::Mul<Integer> for Integer { - type Output = Self; - fn mul(self, other: Self) -> Self { - Self::new(self.value * other.value) + #[inline] + fn is_one(&self) -> bool { + self.value() == 1 } } |