22// the form "<team_1_name>,<team_2_name>,<team_1_goals>,<team_2_goals>"
33// Example: "England,France,4,2" (England scored 4 goals, France 2).
44//
5- // You have to build a scores table containing the name of the team, the total
5+ // You have to build a table of scores containing the name of the team, the total
66// number of goals the team scored, and the total number of goals the team
77// conceded.
88
@@ -15,13 +15,13 @@ struct TeamScores {
1515 goals_conceded : u8 ,
1616}
1717
18- fn build_scores_table ( results : & str ) -> HashMap < & str , TeamScores > {
18+ fn build_score_table ( results : & str ) -> HashMap < & str , TeamScores > {
1919 // The name of the team is the key and its associated struct is the value.
2020 let mut scores = HashMap :: < & str , TeamScores > :: new ( ) ;
2121
2222 for line in results. lines ( ) {
2323 let mut split_iterator = line. split ( ',' ) ;
24- // NOTE: We use `unwrap` because we didn 't deal with error handling yet.
24+ // NOTE: We use `unwrap` because we haven 't dealt with error handling yet.
2525 let team_1_name = split_iterator. next ( ) . unwrap ( ) ;
2626 let team_2_name = split_iterator. next ( ) . unwrap ( ) ;
2727 let team_1_score: u8 = split_iterator. next ( ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
@@ -58,7 +58,7 @@ England,Spain,1,0";
5858
5959 #[ test]
6060 fn build_scores ( ) {
61- let scores = build_scores_table ( RESULTS ) ;
61+ let scores = build_score_table ( RESULTS ) ;
6262
6363 assert ! (
6464 [ "England" , "France" , "Germany" , "Italy" , "Poland" , "Spain" ]
@@ -69,15 +69,15 @@ England,Spain,1,0";
6969
7070 #[ test]
7171 fn validate_team_score_1 ( ) {
72- let scores = build_scores_table ( RESULTS ) ;
72+ let scores = build_score_table ( RESULTS ) ;
7373 let team = scores. get ( "England" ) . unwrap ( ) ;
7474 assert_eq ! ( team. goals_scored, 6 ) ;
7575 assert_eq ! ( team. goals_conceded, 4 ) ;
7676 }
7777
7878 #[ test]
7979 fn validate_team_score_2 ( ) {
80- let scores = build_scores_table ( RESULTS ) ;
80+ let scores = build_score_table ( RESULTS ) ;
8181 let team = scores. get ( "Spain" ) . unwrap ( ) ;
8282 assert_eq ! ( team. goals_scored, 0 ) ;
8383 assert_eq ! ( team. goals_conceded, 3 ) ;
0 commit comments