diff options
| author | liv <mokou@fastmail.com> | 2024-03-15 14:36:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-15 14:36:23 +0100 |
| commit | 76acf613c5481bf7bb44d290b7fb340e71e9faad (patch) | |
| tree | 534cbad29caa892d4026ec593491d05cde541e15 /exercises/23_conversions/from_into.rs | |
| parent | bcb192c707009ab9d9bb06812cb09b9d446ccc11 (diff) | |
| parent | 2966a29449e17eace182c225b3af23fa43af3799 (diff) | |
Merge branch 'main' into main
Diffstat (limited to 'exercises/23_conversions/from_into.rs')
| -rw-r--r-- | exercises/23_conversions/from_into.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/exercises/23_conversions/from_into.rs b/exercises/23_conversions/from_into.rs index 00f8c2f..11787c3 100644 --- a/exercises/23_conversions/from_into.rs +++ b/exercises/23_conversions/from_into.rs @@ -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); } } |
