minor cleanup
This commit is contained in:
parent
8520048b26
commit
bea90060a8
@ -498,7 +498,7 @@ fn repr(red: &Number, green: &Number, blue: &Number, alpha: &Number) -> String {
|
|||||||
|
|
||||||
if alpha < &Number::one() {
|
if alpha < &Number::one() {
|
||||||
format!("rgba({}, {}, {}, {})", red_u8, green_u8, blue_u8, alpha)
|
format!("rgba({}, {}, {}, {})", red_u8, green_u8, blue_u8, alpha)
|
||||||
} else if let Some(c) = NAMED_COLORS.get_by_rgba(&[red_u8, green_u8, blue_u8, 0xFF]) {
|
} else if let Some(c) = NAMED_COLORS.get_by_rgba([red_u8, green_u8, blue_u8, 0xFF]) {
|
||||||
(*c).to_string()
|
(*c).to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("#{:0>2x}{:0>2x}{:0>2x}", red_u8, green_u8, blue_u8)
|
format!("#{:0>2x}{:0>2x}{:0>2x}", red_u8, green_u8, blue_u8)
|
||||||
|
@ -26,8 +26,8 @@ impl NamedColorMap {
|
|||||||
self.name_to_rgba.get(name)
|
self.name_to_rgba.get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_by_rgba(&self, rgba: &[u8; 4]) -> Option<&&str> {
|
pub fn get_by_rgba(&self, rgba: [u8; 4]) -> Option<&&str> {
|
||||||
self.rgba_to_name.get(rgba)
|
self.rgba_to_name.get(&rgba)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,7 @@ impl One for Number {
|
|||||||
|
|
||||||
impl Num for Number {
|
impl Num for Number {
|
||||||
type FromStrRadixErr = SassError;
|
type FromStrRadixErr = SassError;
|
||||||
|
#[cold]
|
||||||
fn from_str_radix(_str: &str, _radix: u32) -> Result<Self, Self::FromStrRadixErr> {
|
fn from_str_radix(_str: &str, _radix: u32) -> Result<Self, Self::FromStrRadixErr> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@ -150,10 +151,12 @@ impl Signed for Number {
|
|||||||
self.abs()
|
self.abs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cold]
|
||||||
fn abs_sub(&self, _: &Self) -> Self {
|
fn abs_sub(&self, _: &Self) -> Self {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cold]
|
||||||
fn signum(&self) -> Self {
|
fn signum(&self) -> Self {
|
||||||
if self.is_zero() {
|
if self.is_zero() {
|
||||||
Self::zero()
|
Self::zero()
|
||||||
@ -236,7 +239,7 @@ impl Display for Number {
|
|||||||
let mut dec = String::with_capacity(if has_decimal { PRECISION + 1 } else { 0 });
|
let mut dec = String::with_capacity(if has_decimal { PRECISION + 1 } else { 0 });
|
||||||
if has_decimal {
|
if has_decimal {
|
||||||
for _ in 0..(PRECISION - 1) {
|
for _ in 0..(PRECISION - 1) {
|
||||||
frac = frac * Self::from(10);
|
frac *= Self::from(10);
|
||||||
write!(dec, "{}", frac.to_integer())?;
|
write!(dec, "{}", frac.to_integer())?;
|
||||||
frac = frac.fract();
|
frac = frac.fract();
|
||||||
if frac.is_zero() {
|
if frac.is_zero() {
|
||||||
|
@ -669,7 +669,7 @@ impl Value {
|
|||||||
|
|
||||||
let n = if val.dec_len == 0 {
|
let n = if val.dec_len == 0 {
|
||||||
if val.num.len() <= 18 && val.times_ten.is_empty() {
|
if val.num.len() <= 18 && val.times_ten.is_empty() {
|
||||||
let n = Rational64::new_raw(val.num.parse::<i64>().unwrap(), 1i64);
|
let n = Rational64::new_raw(val.num.parse::<i64>().unwrap(), 1);
|
||||||
return Some(Ok(IntermediateValue::Value(
|
return Some(Ok(IntermediateValue::Value(
|
||||||
Value::Dimension(Number::new_machine(n), unit).span(span),
|
Value::Dimension(Number::new_machine(n), unit).span(span),
|
||||||
)));
|
)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user