Skip to content

Commit 5e7a5d1

Browse files
authored
Merge pull request rust-lang#2414 from hippietrail/hashmaps3-english-fixes
fix: standard English grammar/phrasing
2 parents d45578d + ab91098 commit 5e7a5d1

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

exercises/11_hashmaps/hashmaps3.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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);

solutions/11_hashmaps/hashmaps3.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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

Comments
 (0)