Skip to content

Commit 630a28b

Browse files
committed
cargo clippy
1 parent eee4804 commit 630a28b

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

crates/dict-to-mozc/src/lib.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ mod utils {
6060
/// Unicode Escapeの記述が含まれる場合、それを変換する。
6161
pub(crate) fn unicode_escape_to_char(text: &str) -> String {
6262
if UNICODE_ESCAPE_RE.is_match(text) {
63-
let result = UNICODE_ESCAPE_RE
63+
64+
// 置換ロジック
65+
UNICODE_ESCAPE_RE
6466
.replace_all(text, |caps: &regex::Captures| {
6567
let num = u32::from_str_radix(&caps[1], 16).unwrap();
6668
std::char::from_u32(num).unwrap().to_string()
6769
})
68-
.into_owned();
69-
// 置換ロジック
70-
result
70+
.into_owned()
7171
} else {
7272
text.to_string()
7373
}
@@ -1084,16 +1084,10 @@ impl DictionaryProcessor for UtDictProcessor {
10841084
*_dict_values.notation = unicode_escape_to_char(_notation);
10851085
let d: String = search_key(_dict_values.id_def, word_class_id).to_owned();
10861086
let word_class = _dict_values.class_map.get(&d);
1087-
if word_class.is_none() {
1088-
*_dict_values.word_class_id = id_expr(
1089-
&d,
1090-
_dict_values.id_def,
1091-
_dict_values.class_map,
1092-
*_dict_values.default_noun_id,
1093-
);
1094-
} else {
1095-
*_dict_values.word_class_id = *word_class.unwrap();
1096-
}
1087+
*_dict_values.word_class_id = match word_class {
1088+
None => id_expr(&d, _dict_values.id_def, _dict_values.class_map, *_dict_values.default_noun_id),
1089+
Some(wc) => *wc,
1090+
};
10971091
let cost_str = record
10981092
.get(_args.cost_index)
10991093
.map_or(DEFAULT_COST.to_string(), |s| s.to_string());
@@ -1147,16 +1141,10 @@ impl DictionaryProcessor for MozcUserDictProcessor {
11471141
*_dict_values.notation = unicode_escape_to_char(_notation);
11481142
let d: String = search_key(_dict_values.id_def, *_dict_values.word_class_id).to_owned();
11491143
let word_class = _dict_values.class_map.get(&d);
1150-
if word_class.is_none() {
1151-
*_dict_values.word_class_id = id_expr(
1152-
&d,
1153-
_dict_values.id_def,
1154-
_dict_values.class_map,
1155-
*_dict_values.default_noun_id,
1156-
);
1157-
} else {
1158-
*_dict_values.word_class_id = *word_class.unwrap();
1159-
}
1144+
*_dict_values.word_class_id = match word_class {
1145+
None => id_expr(&d, _dict_values.id_def, _dict_values.class_map, *_dict_values.default_noun_id),
1146+
Some(wc) => *wc,
1147+
};
11601148
//let cost_str = record.get(_args.cost_index).map_or(DEFAULT_COST.to_string(), |s| s.to_string());
11611149
//let cost = cost_str.parse::<i32>().unwrap_or(DEFAULT_COST);
11621150
let cost = DEFAULT_COST;

src/bin/dict-to-mozc.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
1111
#[cfg(feature = "use-mimalloc-rs")]
1212
#[cfg(all(
1313
feature = "use-mimalloc-rs",
14-
any(
15-
all(not(target_os = "windows"))
16-
)
14+
not(target_os = "windows")
1715
))]
1816
#[global_allocator]
1917
static GLOBAL_MIMALLOC: mimalloc_rust::GlobalMiMalloc = mimalloc_rust::GlobalMiMalloc;

0 commit comments

Comments
 (0)