Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
style: Use style::One for Integer to avoid implementing Mul.
  • Loading branch information
BorisChiou authored and emilio committed Jun 3, 2020
1 parent 7022f45 commit 35546ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions components/style/values/generics/font.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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)?;
}
Expand Down
12 changes: 4 additions & 8 deletions components/style/values/specified/mod.rs
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 35546ae

Please sign in to comment.