From bf5f448897ebf98e4386b5335015e2a51d83f2c9 Mon Sep 17 00:00:00 2001 From: mrkmntal Date: Thu, 24 Sep 2026 22:27:47 -0400 Subject: [PATCH] Code Cleanup for my preferred format --- .rustfmt.toml | 1 + src/main.rs | 15 ++++++++++----- src/tsrc.rs | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 .rustfmt.toml diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..c7ad93b --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1 @@ +disable_all_formatting = true diff --git a/src/main.rs b/src/main.rs index 47d8a46..0d8832e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,7 +149,8 @@ fn gen_match( let shots = home_score.max(rng.gen_range(4..=18u8)); let on_target = home_score.max(rng.gen_range(1..=shots.min(10))); (shots, on_target) - } else { + } + else { let shots = rng.gen_range(4..=18u8); let on_target = rng.gen_range(1..=shots.min(10)); (shots, on_target) @@ -159,7 +160,8 @@ fn gen_match( let shots = away_score.max(rng.gen_range(4..=18u8)); let on_target = away_score.max(rng.gen_range(1..=shots.min(10))); (shots, on_target) - } else { + } + else { let shots = rng.gen_range(4..=18u8); let on_target = rng.gen_range(1..=shots.min(10)); (shots, on_target) @@ -212,7 +214,8 @@ fn print_table(m: &Match) { lines.push("Goals:".to_string()); if m.home.scorers.is_empty() && m.away.scorers.is_empty() { lines.push("No goals scored.".to_string()); - } else { + } + else { for (name, min) in &m.home.scorers { lines.push(format!("{home}: {name} ({min}')")); } @@ -314,7 +317,8 @@ fn main() { process::exit(1); } } - } else { + } + else { args.iter() .skip(1) .find(|a| !a.starts_with("--") && Path::new(a).is_file()) @@ -331,7 +335,8 @@ fn main() { if json_mode { print_json(&m); - } else { + } + else { print_table(&m); } } diff --git a/src/tsrc.rs b/src/tsrc.rs index 641ada5..4bafb04 100644 --- a/src/tsrc.rs +++ b/src/tsrc.rs @@ -42,16 +42,20 @@ pub fn parse_tsrc(path: &str) -> Result { if let Some(rest) = line.strip_prefix("string ") { parse_string_decl(rest, n, &mut teams, &mut var_lines)?; - } else if let Some(rest) = line.strip_prefix("players") { + } + else if let Some(rest) = line.strip_prefix("players") { parse_player_insert(rest, n, &mut roster, &mut player_entries, &teams)?; - } else if let Some(rest) = line.strip_prefix("goal") { + } + else if let Some(rest) = line.strip_prefix("goal") { let goal = parse_goal(rest, n, &teams, &roster, &mut goal_entries)?; goals.push(goal); - } else if let Some(rest) = line.strip_prefix("match") { + } + else if let Some(rest) = line.strip_prefix("match") { let rest = rest.trim_end_matches(';'); (home_var, away_var) = parse_match(rest, n, &teams)?; match_found = true; - } else { + } + else { return Err(format!("tsrc error: unrecognized statement on line {}: '{}'", n, line)); } } @@ -172,7 +176,8 @@ fn parse_player_insert( let team_name = if value_part.starts_with('"') { parse_string_literal(value_part, n)? - } else { + } + else { let var_name = value_part.trim(); if !is_valid_ident(var_name) { return Err(format!( @@ -269,7 +274,8 @@ fn parse_goal( let team_part = parts[1].trim(); let team_name = if team_part.starts_with('"') { parse_string_literal(team_part, n)? - } else { + } + else { if !is_valid_ident(team_part) { return Err(format!( "tsrc error: goal() team must be a string literal or variable on line {}",