diff --git a/src/color/mod.rs b/src/color/mod.rs index 5f58328..6f2c65a 100644 --- a/src/color/mod.rs +++ b/src/color/mod.rs @@ -1,7 +1,7 @@ use std::fmt::{self, Display}; +use crate::value::Number; pub(crate) use name::ColorName; -use crate::value::{Number, Value}; mod name; diff --git a/src/lexer.rs b/src/lexer.rs index 17c05d1..11882eb 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -48,9 +48,9 @@ impl<'a> Iterator for Lexer<'a> { s.push_str(&n); TokenKind::Number(s) } - _ => unsafe { std::hint::unreachable_unchecked() } - } - _ => TokenKind::Symbol(Symbol::Period) + _ => unsafe { std::hint::unreachable_unchecked() }, + }, + _ => TokenKind::Symbol(Symbol::Period), } } '$' => self.lex_variable(), diff --git a/src/value/number.rs b/src/value/number.rs index 91c2f1a..787ce65 100644 --- a/src/value/number.rs +++ b/src/value/number.rs @@ -1,6 +1,6 @@ use std::convert::From; use std::fmt::{self, Display, Write}; -use std::ops::{Add, Sub, Mul, Div}; +use std::ops::{Add, Div, Mul, Sub}; use num_bigint::BigInt; use num_rational::BigRational; @@ -53,9 +53,14 @@ impl Display for Number { } } if frac != BigRational::from_integer(BigInt::from(0)) { - write!(f, "{}", (frac * BigRational::from_integer(BigInt::from(10))).round().to_integer())?; + write!( + f, + "{}", + (frac * BigRational::from_integer(BigInt::from(10))) + .round() + .to_integer() + )?; } - } Ok(()) } diff --git a/src/value/parse.rs b/src/value/parse.rs index 05d3f41..1a5543b 100644 --- a/src/value/parse.rs +++ b/src/value/parse.rs @@ -1,8 +1,8 @@ use std::convert::TryFrom; use std::iter::{Iterator, Peekable}; -use num_rational::BigRational; use num_bigint::BigInt; +use num_rational::BigRational; use num_traits::pow; use crate::args::eat_call_args; @@ -188,10 +188,7 @@ impl Value { BigRational::new(num.parse().unwrap(), pow(BigInt::from(10), num_dec)) } }; - Some(Value::Dimension( - Number::new(n), - unit, - )) + Some(Value::Dimension(Number::new(n), unit)) } TokenKind::Symbol(Symbol::OpenParen) => { devour_whitespace_or_comment(toks); diff --git a/tests/color.rs b/tests/color.rs index 5c1a5b3..9d42f5a 100644 --- a/tests/color.rs +++ b/tests/color.rs @@ -56,10 +56,7 @@ test!( "a {\n color: alpha(red);\n}\n", "a {\n color: 1;\n}\n" ); -test!( - opacity_function_number, - "a {\n color: opacity(1);\n}\n" -); +test!(opacity_function_number, "a {\n color: opacity(1);\n}\n"); test!( opacity_function_number_unit, "a {\n color: opacity(1px);\n}\n" @@ -78,4 +75,4 @@ test!( rgba_opacity_percent, "a {\n color: rgba(1, 2, 3, 50%);\n}\n", "a {\n color: rgba(1, 2, 3, 0.5);\n}\n" -); \ No newline at end of file +);