improve
This commit is contained in:
@@ -40,27 +40,29 @@ fn build_scores_table(results: String) -> HashMap<String, Team> {
|
|||||||
// will be the number of goals conceded by team_2, and similarly
|
// will be the number of goals conceded by team_2, and similarly
|
||||||
// goals scored by team_2 will be the number of goals conceded by
|
// goals scored by team_2 will be the number of goals conceded by
|
||||||
// team_1.
|
// team_1.
|
||||||
for team in vec![&team_1_name, &team_2_name] {
|
if let Some(t) = scores.get_mut(&team_1_name) {
|
||||||
if !scores.contains_key(team) {
|
t.goals_scored += team_1_score;
|
||||||
let t = Team {
|
t.goals_conceded += team_2_score;
|
||||||
goals_scored: 0,
|
} else {
|
||||||
goals_conceded: 0,
|
let t = Team {
|
||||||
};
|
goals_scored: team_1_score,
|
||||||
|
goals_conceded: team_2_score,
|
||||||
|
};
|
||||||
|
|
||||||
scores.insert(team.to_string(), t);
|
scores.insert(team_1_name.to_string(), t);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{}", &team_1_name);
|
if let Some(t) = scores.get_mut(&team_2_name) {
|
||||||
println!("{}", &team_2_name);
|
t.goals_scored += team_2_score;
|
||||||
|
t.goals_conceded += team_1_score;
|
||||||
let mut t = scores.get_mut(&team_1_name).unwrap();
|
} else {
|
||||||
t.goals_scored += team_1_score;
|
let t = Team {
|
||||||
t.goals_conceded += team_2_score;
|
goals_scored: team_2_score,
|
||||||
|
goals_conceded: team_1_score,
|
||||||
let mut t = scores.get_mut(&team_2_name).unwrap();
|
};
|
||||||
t.goals_scored += team_2_score;
|
|
||||||
t.goals_conceded += team_1_score;
|
scores.insert(team_2_name.to_string(), t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
scores
|
scores
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user