diff --git a/src/bin/fmt-tssr.rs b/src/bin/fmt-tssr.rs index 6d1e21a..f23d6dd 100644 --- a/src/bin/fmt-tssr.rs +++ b/src/bin/fmt-tssr.rs @@ -17,8 +17,7 @@ fn format_file(path: &Path) -> Result { if trimmed == "{" && !line.trim_start().starts_with("//") - && !line.trim_start().starts_with("/*") - { + && !line.trim_start().starts_with("/*") { if let Some(last) = out.last() { let merged = format!("{} {{", last.trim_end()); out.pop(); @@ -30,8 +29,7 @@ fn format_file(path: &Path) -> Result { } if (trimmed.starts_with("} else ") || trimmed == "} else" || trimmed.starts_with("} else if")) - && !line.trim_start().starts_with("//") - { + && !line.trim_start().starts_with("//") { let idx = line.rfind('}').unwrap(); let before = &line[..idx + 1]; let after = &line[idx + 1..]; @@ -44,16 +42,20 @@ fn format_file(path: &Path) -> Result { if rest.ends_with('{') { let header = rest.trim_end_matches('{').trim_end(); format!("{}{} {{", indent, header) - } else { + } + else { format!("{}{}", indent, rest.trim()) } - } else if after.trim() == "else {" || after.trim() == "else" { + } + else if after.trim() == "else {" || after.trim() == "else" { if after.trim().ends_with('{') { format!("{}else {{", indent) - } else { + } + else { format!("{}else", indent) } - } else { + } + else { format!("{}{}", indent, after.trim()) }; out.push(next_line); @@ -69,7 +71,8 @@ fn format_file(path: &Path) -> Result { let result = out.join("\n"); let final_content = if content.ends_with('\n') { format!("{}\n", result) - } else { + } + else { result }; @@ -88,7 +91,8 @@ fn find_rs_files(dir: &Path) -> Vec { let path = entry.path(); if path.is_dir() { files.extend(find_rs_files(&path)); - } else if path.extension().map_or(false, |e| e == "rs") { + } + else if path.extension().map_or(false, |e| e == "rs") { if let Some(name) = path.file_name() { if name != "fmt-tssr.rs" { files.push(path); @@ -107,11 +111,13 @@ fn collect_targets(args: &[String]) -> Vec { let p = std::path::PathBuf::from(arg); if p.is_file() { targets.push(p); - } else if p.is_dir() { + } + else if p.is_dir() { targets.extend(find_rs_files(&p)); } } - } else { + } + else { let src_dir = std::path::PathBuf::from("src"); if src_dir.exists() { targets.extend(find_rs_files(&src_dir));