Skip to content

Commit aa91363

Browse files
committed
clean code
1 parent b45bab4 commit aa91363

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

tools/std_i18n/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "std_i18n"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
# local

tools/std_i18n/src/comment_syntax.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ pub fn build_tag_line_indexes(raw: &str, lines: &[LineInfo]) -> TagLineIndexes {
181181
return_lines.push(i);
182182
continue;
183183
}
184-
if t.starts_with("---|") {
185-
if let Some(value) = parse_union_item_value_from_line_trim(t) {
186-
union_line.entry(value).or_insert(i);
187-
}
184+
if t.starts_with("---|")
185+
&& let Some(value) = parse_union_item_value_from_line_trim(t)
186+
{
187+
union_line.entry(value).or_insert(i);
188188
}
189189
}
190190

tools/std_i18n/src/extractor.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ pub fn analyze_lua_doc_file(
110110
let has_owner = comment.get_owner().is_some();
111111

112112
let mut effective_version = direct_version.clone();
113-
if effective_version.is_none() {
114-
if let Some((pending, pending_end)) = pending_version.as_ref() {
115-
if has_owner && is_whitespace_between(content, *pending_end, start) {
116-
effective_version = Some(pending.clone());
117-
}
118-
}
113+
if effective_version.is_none()
114+
&& let Some((pending, pending_end)) = pending_version.as_ref()
115+
&& has_owner
116+
&& is_whitespace_between(content, *pending_end, start)
117+
{
118+
effective_version = Some(pending.clone());
119119
}
120120

121121
for symbol in root_symbols_for_comment(&comment, &raw_comment) {
@@ -687,10 +687,10 @@ fn preprocess_description(description: &str) -> String {
687687

688688
if let Some(true) = start_with_one_space {
689689
let mut chars = line.chars();
690-
if let Some(first) = chars.next() {
691-
if first.is_whitespace() {
692-
line = chars.as_str();
693-
}
690+
if let Some(first) = chars.next()
691+
&& first.is_whitespace()
692+
{
693+
line = chars.as_str();
694694
}
695695
}
696696

@@ -706,11 +706,11 @@ fn extract_version_suffix(comment: &LuaComment, raw_comment: &str) -> Option<Str
706706
for tag in comment.get_doc_tags() {
707707
if let LuaDocTag::Version(version_tag) = tag {
708708
let raw = version_tag.syntax().text().to_string();
709-
if let Some(remainder) = extract_version_remainder(&raw) {
710-
if !remainder.is_empty() {
711-
let compact = remainder.split_whitespace().collect::<String>();
712-
return Some(format!("@{compact}"));
713-
}
709+
if let Some(remainder) = extract_version_remainder(&raw)
710+
&& !remainder.is_empty()
711+
{
712+
let compact = remainder.split_whitespace().collect::<String>();
713+
return Some(format!("@{compact}"));
714714
}
715715
}
716716
}

tools/std_i18n/src/keys.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ pub fn map_symbol_for_locale_key(symbol: &str, module_map: &HashMap<String, Stri
5757
if let Some(class) = module_map.get(symbol) {
5858
s = class.clone();
5959
}
60-
if let Some((first, rest)) = s.split_once('.') {
61-
if let Some(class) = module_map.get(first) {
62-
s = format!("{class}.{rest}");
63-
}
60+
if let Some((first, rest)) = s.split_once('.')
61+
&& let Some(class) = module_map.get(first)
62+
{
63+
s = format!("{class}.{rest}");
6464
}
6565
s.replace(':', ".")
6666
}

tools/std_i18n/src/translator.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::comment_syntax::{
2-
build_tag_line_indexes, is_doc_tag_line, normalize_optional_name, split_lines_with_offsets,
3-
LineInfo,
2+
LineInfo, build_tag_line_indexes, is_doc_tag_line, normalize_optional_name,
3+
split_lines_with_offsets,
44
};
55
use crate::extractor::analyze_lua_doc_file;
66
use crate::model::{ExtractedEntry, ExtractedKind, SourceSpan};
@@ -193,10 +193,10 @@ fn tag_attached_replace_target_after(
193193
return Some(inline);
194194
}
195195

196-
if raw_desc.trim().is_empty() {
197-
if let Some(insert) = inline_tag_description_insert_target(ctx, comment_span, tag_idx) {
198-
return Some(insert);
199-
}
196+
if raw_desc.trim().is_empty()
197+
&& let Some(insert) = inline_tag_description_insert_target(ctx, comment_span, tag_idx)
198+
{
199+
return Some(insert);
200200
}
201201

202202
attached_doc_block_target_after(ctx, comment_span, tag_idx, file_content)

0 commit comments

Comments
 (0)