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,19 +15,19 @@ 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 ( ) ;
2828 let team_2_score: u8 = split_iterator. next ( ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
2929
30- // TODO: Populate the scores table with the extracted details.
30+ // TODO: Populate the score table with the extracted details.
3131 // Keep in mind that goals scored by team 1 will be the number of goals
3232 // conceded by team 2. Similarly, goals scored by team 2 will be the
3333 // number of goals conceded by team 1.
@@ -52,7 +52,7 @@ England,Spain,1,0";
5252
5353 #[ test]
5454 fn build_scores ( ) {
55- let scores = build_scores_table ( RESULTS ) ;
55+ let scores = build_score_table ( RESULTS ) ;
5656
5757 assert ! ( [ "England" , "France" , "Germany" , "Italy" , "Poland" , "Spain" ]
5858 . into_iter( )
@@ -61,15 +61,15 @@ England,Spain,1,0";
6161
6262 #[ test]
6363 fn validate_team_score_1 ( ) {
64- let scores = build_scores_table ( RESULTS ) ;
64+ let scores = build_score_table ( RESULTS ) ;
6565 let team = scores. get ( "England" ) . unwrap ( ) ;
6666 assert_eq ! ( team. goals_scored, 6 ) ;
6767 assert_eq ! ( team. goals_conceded, 4 ) ;
6868 }
6969
7070 #[ test]
7171 fn validate_team_score_2 ( ) {
72- let scores = build_scores_table ( RESULTS ) ;
72+ let scores = build_score_table ( RESULTS ) ;
7373 let team = scores. get ( "Spain" ) . unwrap ( ) ;
7474 assert_eq ! ( team. goals_scored, 0 ) ;
7575 assert_eq ! ( team. goals_conceded, 3 ) ;
0 commit comments