feat: Rewrite try_from_into (#393)

This commit is contained in:
IkaR49
2020-05-16 00:02:57 +03:00
committed by GitHub
parent d6c0a688e6
commit 763aa6e378
3 changed files with 91 additions and 61 deletions

View File

@@ -17,6 +17,7 @@ struct Person {
// 3. Extract the first element from the split operation and use it as the name
// 4. If the name is empty, then return an error
// 5. Extract the other element from the split operation and parse it into a `usize` as the age
// with something like `"4".parse::<usize>()`.
// If while parsing the age, something goes wrong, then return an error
// Otherwise, then return a Result of a Person object
impl FromStr for Person {
@@ -82,4 +83,4 @@ mod tests {
",one".parse::<Person>().unwrap();
}
}
}