summaryrefslogtreecommitdiff
path: root/exercises/conversions/from_str.rs
diff options
context:
space:
mode:
Diffstat (limited to 'exercises/conversions/from_str.rs')
-rw-r--r--exercises/conversions/from_str.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs
index ece0b3c..fe16815 100644
--- a/exercises/conversions/from_str.rs
+++ b/exercises/conversions/from_str.rs
@@ -4,6 +4,8 @@
// Additionally, upon implementing FromStr, you can use the `parse` method
// on strings to generate an object of the implementor type.
// You can read more about it at https://doc.rust-lang.org/std/str/trait.FromStr.html
+// Execute `rustlings hint from_str` or use the `hint` watch subcommand for a hint.
+
use std::num::ParseIntError;
use std::str::FromStr;
@@ -37,6 +39,9 @@ enum ParsePersonError {
// with something like `"4".parse::<usize>()`
// 6. If while extracting the name and the age something goes wrong, an error should be returned
// If everything goes well, then return a Result of a Person object
+//
+// As an aside: `Box<dyn Error>` implements `From<&'_ str>`. This means that if you want to return a
+// string error message, you can do so via just using return `Err("my error message".into())`.
impl FromStr for Person {
type Err = ParsePersonError;