diff options
Diffstat (limited to 'rustlings/exercises/11_hashmaps/hashmaps3.rs')
| -rw-r--r-- | rustlings/exercises/11_hashmaps/hashmaps3.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/rustlings/exercises/11_hashmaps/hashmaps3.rs b/rustlings/exercises/11_hashmaps/hashmaps3.rs index 5b390ab..0fa4a6b 100644 --- a/rustlings/exercises/11_hashmaps/hashmaps3.rs +++ b/rustlings/exercises/11_hashmaps/hashmaps3.rs @@ -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 team_1 = scores.entry(team_1_name).or_default(); + team_1.goals_scored += team_1_score; + team_1.goals_conceded += team_2_score; + let team_2 = scores.entry(team_2_name).or_default(); + team_2.goals_scored += team_2_score; + team_2.goals_conceded += team_1_score; + } scores |