Merge branch 'main' into main

This commit is contained in:
liv
2024-03-15 14:36:23 +01:00
committed by GitHub
12 changed files with 131 additions and 57 deletions

View File

@@ -4,10 +4,11 @@
// the form : "<team_1_name>,<team_2_name>,<team_1_goals>,<team_2_goals>"
// Example: England,France,4,2 (England scored 4 goals, France 2).
//
// You have to build a scores table containing the name of the team, goals the
// team scored, and goals the team conceded. One approach to build the scores
// table is to use a Hashmap. The solution is partially written to use a
// Hashmap, complete it to pass the test.
// You have to build a scores table containing the name of the team, the total
// number of goals the team scored, and the total number of goals the team
// conceded. One approach to build the scores table is to use a Hashmap.
// The solution is partially written to use a Hashmap,
// complete it to pass the test.
//
// Make me pass the tests!
//

View File

@@ -24,7 +24,8 @@ impl Default for Person {
}
}
// Your task is to complete this implementation in order for the line `let p =
// Your task is to complete this implementation in order for the line `let p1 =
// Person::from("Mark,20")` to compile. Please note that you'll need to parse the
// age component into a `usize` with something like `"4".parse::<usize>()`. The
// outcome of this needs to be handled appropriately.
@@ -43,8 +44,7 @@ impl Default for Person {
// I AM NOT DONE
impl From<&str> for Person {
fn from(s: &str) -> Person {
}
fn from(s: &str) -> Person {}
}
fn main() {
@@ -127,14 +127,14 @@ mod tests {
#[test]
fn test_trailing_comma() {
let p: Person = Person::from("Mike,32,");
assert_eq!(p.name, "Mike");
assert_eq!(p.age, 32);
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
#[test]
fn test_trailing_comma_and_some_string() {
let p: Person = Person::from("Mike,32,man");
assert_eq!(p.name, "Mike");
assert_eq!(p.age, 32);
let p: Person = Person::from("Mike,32,dog");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
}