wip
This commit is contained in:
@@ -14,8 +14,6 @@
|
|||||||
// Execute `rustlings hint hashmaps2` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint hashmaps2` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Hash, PartialEq, Eq)]
|
#[derive(Hash, PartialEq, Eq)]
|
||||||
@@ -40,6 +38,10 @@ fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
|
|||||||
// TODO: Insert new fruits if they are not already present in the
|
// TODO: Insert new fruits if they are not already present in the
|
||||||
// basket. Note that you are not allowed to put any type of fruit that's
|
// basket. Note that you are not allowed to put any type of fruit that's
|
||||||
// already present!
|
// already present!
|
||||||
|
|
||||||
|
if !basket.contains_key(&fruit) {
|
||||||
|
basket.insert(fruit, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,27 @@ 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 !scores.contains_key(team) {
|
||||||
|
let t = Team {
|
||||||
|
goals_scored: 0,
|
||||||
|
goals_conceded: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
scores.insert(team.to_string(), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("{}", &team_1_name);
|
||||||
|
println!("{}", &team_2_name);
|
||||||
|
|
||||||
|
let mut t = scores.get_mut(&team_1_name).unwrap();
|
||||||
|
t.goals_scored += team_1_score;
|
||||||
|
t.goals_conceded += team_2_score;
|
||||||
|
|
||||||
|
let mut t = scores.get_mut(&team_2_name).unwrap();
|
||||||
|
t.goals_scored += team_2_score;
|
||||||
|
t.goals_conceded += team_1_score;
|
||||||
}
|
}
|
||||||
scores
|
scores
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user