feat: completed solutions

This commit is contained in:
2026-03-23 03:36:33 -04:00
parent 2279bea6f1
commit f568c094cb
65 changed files with 424 additions and 139 deletions
+12 -1
View File
@@ -34,7 +34,18 @@ impl Default for Person {
// 5. Parse the second element from the split operation into a `u8` as the age.
// 6. If parsing the age fails, return the default of `Person`.
impl From<&str> for Person {
fn from(s: &str) -> Self {}
fn from(s: &str) -> Self {
match s.split(",").collect::<Vec<&str>>().as_slice() {
[name, age] if (!name.is_empty() && !age.is_empty()) => match age.parse::<u8>() {
Ok(age) => Person {
name: name.to_string(),
age,
},
Err(_) => Person::default(),
},
_ => Person::default(),
}
}
}
fn main() {