Skip to content

Commit f09bf2b

Browse files
committed
Fix lint
1 parent 0a4d382 commit f09bf2b

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

bindings/devup-ui-wasm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub fn get_default_theme() -> Result<Option<String>, JsValue> {
285285
#[wasm_bindgen(js_name = "getCss")]
286286
pub fn get_css(file_num: Option<usize>) -> Result<String, JsValue> {
287287
let sheet = GLOBAL_STYLE_SHEET.lock().unwrap();
288-
Ok(sheet.create_css(file_num.map(|num| get_filename_by_file_num(num)).as_deref()))
288+
Ok(sheet.create_css(file_num.map(get_filename_by_file_num).as_deref()))
289289
}
290290

291291
#[wasm_bindgen(js_name = "getThemeInterface")]

libs/css/src/file_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn get_file_num_by_filename(filename: &str) -> usize {
2525
let mut map = GLOBAL_FILE_MAP.lock().unwrap();
2626
let len = map.len();
2727
if !map.contains_left(filename) {
28-
map.insert(filename.to_string(), len as usize);
28+
map.insert(filename.to_string(), len);
2929
}
3030
*map.get_by_left(filename).unwrap()
3131
}

libs/css/src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod selector_separator;
1111
pub mod style_selector;
1212
pub mod utils;
1313

14-
use std::collections::HashMap;
1514
use std::hash::{DefaultHasher, Hash, Hasher};
1615

1716
use crate::class_map::GLOBAL_CLASS_MAP;
@@ -75,14 +74,14 @@ pub fn keyframes_to_keyframes_name(keyframes: &str, filename: Option<&str>) -> S
7574
let filename = filename.unwrap_or_default().to_string();
7675
let class_num = map
7776
.entry(filename.to_string())
78-
.or_insert_with(HashMap::new)
77+
.or_default()
7978
.get(&key)
80-
.map(|v| format!("{}", num_to_nm_base(*v)))
79+
.map(|v| num_to_nm_base(*v).to_string())
8180
.unwrap_or_else(|| {
82-
let m = map.entry(filename.to_string()).or_insert_with(HashMap::new);
81+
let m = map.entry(filename.to_string()).or_default();
8382
let len = m.len();
8483
m.insert(key, len);
85-
format!("{}", num_to_nm_base(len))
84+
num_to_nm_base(len).to_string()
8685
});
8786
if !filename.is_empty() {
8887
format!(
@@ -139,11 +138,11 @@ pub fn sheet_to_classname(
139138
let filename = filename.map(|v| v.to_string()).unwrap_or_default();
140139
let clas_num = map
141140
.entry(filename.to_string())
142-
.or_insert_with(HashMap::new)
141+
.or_default()
143142
.get(&key)
144143
.map(|v| num_to_nm_base(*v))
145144
.unwrap_or_else(|| {
146-
let m = map.entry(filename.to_string()).or_insert_with(HashMap::new);
145+
let m = map.entry(filename.to_string()).or_default();
147146
let len = m.len();
148147
m.insert(key, len);
149148
num_to_nm_base(len)
@@ -184,11 +183,11 @@ pub fn sheet_to_variable_name(property: &str, level: u8, selector: Option<&str>)
184183
);
185184
let mut map = GLOBAL_CLASS_MAP.lock().unwrap();
186185
map.entry("".to_string())
187-
.or_insert_with(HashMap::new)
186+
.or_default()
188187
.get(&key)
189188
.map(|v| format!("--{}", num_to_nm_base(*v)))
190189
.unwrap_or_else(|| {
191-
let m = map.entry("".to_string()).or_insert_with(HashMap::new);
190+
let m = map.entry("".to_string()).or_default();
192191
let len = m.len();
193192
m.insert(key, len);
194193
format!("--{}", num_to_nm_base(len))

libs/sheet/src/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ impl ExtractStyle for StyleSheetCss {
101101
}
102102

103103
type PropertyMap = BTreeMap<u8, BTreeMap<u8, HashSet<StyleSheetProperty>>>;
104+
type KeyframesMap = BTreeMap<String, BTreeMap<String, BTreeMap<String, Vec<(String, String)>>>>;
104105

105106
fn deserialize_btree_map_u8<'de, D>(
106107
deserializer: D,
@@ -135,7 +136,7 @@ pub struct StyleSheet {
135136
pub properties: BTreeMap<String, PropertyMap>,
136137
pub css: BTreeMap<String, BTreeSet<StyleSheetCss>>,
137138
#[serde(default)]
138-
pub keyframes: BTreeMap<String, BTreeMap<String, BTreeMap<String, Vec<(String, String)>>>>,
139+
pub keyframes: KeyframesMap,
139140
#[serde(default)]
140141
pub global_css_files: BTreeSet<String>,
141142
#[serde(default)]
@@ -147,6 +148,7 @@ pub struct StyleSheet {
147148
}
148149

149150
impl StyleSheet {
151+
#[allow(clippy::too_many_arguments)]
150152
pub fn add_property(
151153
&mut self,
152154
class_name: &str,
@@ -341,10 +343,7 @@ impl StyleSheet {
341343
css.push_str("@import \"./devup-ui.css\";");
342344
}
343345

344-
if let Some(keyframes) = self
345-
.keyframes
346-
.get(&filename.unwrap_or_default().to_string())
347-
{
346+
if let Some(keyframes) = self.keyframes.get(filename.unwrap_or_default()) {
348347
for (name, map) in keyframes {
349348
css.push_str(&format!(
350349
"@keyframes {name}{{{}}}",
@@ -363,10 +362,7 @@ impl StyleSheet {
363362
}
364363

365364
// order
366-
if let Some(maps) = self
367-
.properties
368-
.get(&filename.unwrap_or_default().to_string())
369-
{
365+
if let Some(maps) = self.properties.get(filename.unwrap_or_default()) {
370366
for (_, map) in maps.iter() {
371367
for (level, props) in map.iter() {
372368
let (mut global_props, rest): (Vec<_>, Vec<_>) =

0 commit comments

Comments
 (0)