rustfmt
This commit is contained in:
parent
c75e5cc553
commit
6c8dd6de93
@ -1,7 +1,7 @@
|
|||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
|
use crate::value::Number;
|
||||||
pub(crate) use name::ColorName;
|
pub(crate) use name::ColorName;
|
||||||
use crate::value::{Number, Value};
|
|
||||||
|
|
||||||
mod name;
|
mod name;
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ impl<'a> Iterator for Lexer<'a> {
|
|||||||
s.push_str(&n);
|
s.push_str(&n);
|
||||||
TokenKind::Number(s)
|
TokenKind::Number(s)
|
||||||
}
|
}
|
||||||
_ => unsafe { std::hint::unreachable_unchecked() }
|
_ => unsafe { std::hint::unreachable_unchecked() },
|
||||||
}
|
},
|
||||||
_ => TokenKind::Symbol(Symbol::Period)
|
_ => TokenKind::Symbol(Symbol::Period),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'$' => self.lex_variable(),
|
'$' => self.lex_variable(),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
use std::fmt::{self, Display, Write};
|
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_bigint::BigInt;
|
||||||
use num_rational::BigRational;
|
use num_rational::BigRational;
|
||||||
@ -53,9 +53,14 @@ impl Display for Number {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if frac != BigRational::from_integer(BigInt::from(0)) {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::iter::{Iterator, Peekable};
|
use std::iter::{Iterator, Peekable};
|
||||||
|
|
||||||
use num_rational::BigRational;
|
|
||||||
use num_bigint::BigInt;
|
use num_bigint::BigInt;
|
||||||
|
use num_rational::BigRational;
|
||||||
use num_traits::pow;
|
use num_traits::pow;
|
||||||
|
|
||||||
use crate::args::eat_call_args;
|
use crate::args::eat_call_args;
|
||||||
@ -188,10 +188,7 @@ impl Value {
|
|||||||
BigRational::new(num.parse().unwrap(), pow(BigInt::from(10), num_dec))
|
BigRational::new(num.parse().unwrap(), pow(BigInt::from(10), num_dec))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Some(Value::Dimension(
|
Some(Value::Dimension(Number::new(n), unit))
|
||||||
Number::new(n),
|
|
||||||
unit,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
TokenKind::Symbol(Symbol::OpenParen) => {
|
TokenKind::Symbol(Symbol::OpenParen) => {
|
||||||
devour_whitespace_or_comment(toks);
|
devour_whitespace_or_comment(toks);
|
||||||
|
@ -56,10 +56,7 @@ test!(
|
|||||||
"a {\n color: alpha(red);\n}\n",
|
"a {\n color: alpha(red);\n}\n",
|
||||||
"a {\n color: 1;\n}\n"
|
"a {\n color: 1;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(opacity_function_number, "a {\n color: opacity(1);\n}\n");
|
||||||
opacity_function_number,
|
|
||||||
"a {\n color: opacity(1);\n}\n"
|
|
||||||
);
|
|
||||||
test!(
|
test!(
|
||||||
opacity_function_number_unit,
|
opacity_function_number_unit,
|
||||||
"a {\n color: opacity(1px);\n}\n"
|
"a {\n color: opacity(1px);\n}\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user