Completed hashmaps
This commit is contained in:
@@ -31,6 +31,13 @@ fn build_scores_table(results: &str) -> HashMap<&str, TeamScores> {
|
||||
// Keep in mind that goals scored by team 1 will be the number of goals
|
||||
// conceded by team 2. Similarly, goals scored by team 2 will be the
|
||||
// number of goals conceded by team 1.
|
||||
let scores1= scores.entry(team_1_name).or_insert(TeamScores { goals_scored: (0), goals_conceded: (0) });
|
||||
scores1.goals_scored += team_1_score;
|
||||
scores1.goals_conceded += team_2_score;
|
||||
|
||||
let scores2= scores.entry(team_2_name).or_insert(TeamScores { goals_scored: (0), goals_conceded: (0) });
|
||||
scores2.goals_scored += team_2_score;
|
||||
scores2.goals_conceded += team_1_score;
|
||||
}
|
||||
|
||||
scores
|
||||
|
||||
Reference in New Issue
Block a user