Skip to content

Commit bd710c7

Browse files
committed
Fix testcase
1 parent b714899 commit bd710c7

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

libs/sheet/src/theme.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,17 @@ impl<'de> Deserialize<'de> for TokenValues {
359359
Value::String(s) => result.push(Some(s.clone())),
360360
Value::Number(n) => result.push(Some(n.to_string())),
361361
_ => {
362-
return Err(serde::de::Error::custom(format!(
363-
"Invalid token value in array: {item:?}"
364-
)));
362+
let msg = format!("Invalid token value: {item:?}");
363+
return Err(serde::de::Error::custom(msg));
365364
}
366365
}
367366
}
368367
Ok(Self(result))
369368
}
370-
_ => Err(serde::de::Error::custom(format!(
371-
"Token value must be a string, number, or array, got: {value:?}"
372-
))),
369+
_ => {
370+
let msg = format!("Expected string, number, or array, got: {value:?}");
371+
Err(serde::de::Error::custom(msg))
372+
}
373373
}
374374
}
375375
}
@@ -390,6 +390,7 @@ fn number_to_length(n: &serde_json::Number) -> String {
390390
format!("{v}px")
391391
} else if let Some(f) = n.as_f64() {
392392
let val = f * 4.0;
393+
#[allow(clippy::cast_possible_truncation)]
393394
if val.fract() == 0.0 {
394395
let v = val as i64;
395396
format!("{v}px")
@@ -689,6 +690,8 @@ impl Theme {
689690
themes: &BTreeMap<String, BTreeMap<String, TokenValues>>,
690691
breakpoints: &[u16],
691692
) {
693+
use std::cmp::Ordering;
694+
692695
if themes.is_empty() {
693696
return;
694697
}
@@ -704,8 +707,8 @@ impl Theme {
704707
// Sort variants: default first, then alphabetical
705708
let mut sorted_variants: Vec<_> = themes.iter().collect();
706709
sorted_variants.sort_by(|a, b| match (a.0 == &default_key, b.0 == &default_key) {
707-
(true, _) => std::cmp::Ordering::Less,
708-
(_, true) => std::cmp::Ordering::Greater,
710+
(true, _) => Ordering::Less,
711+
(_, true) => Ordering::Greater,
709712
_ => a.0.cmp(b.0),
710713
});
711714

0 commit comments

Comments
 (0)