diff --git a/exercises/conversions/from_into.rs b/exercises/conversions/from_into.rs index 9d84174..6c272c3 100644 --- a/exercises/conversions/from_into.rs +++ b/exercises/conversions/from_into.rs @@ -1,6 +1,8 @@ // The From trait is used for value-to-value conversions. // If From is implemented correctly for a type, the Into trait should work conversely. // You can read more about it at https://doc.rust-lang.org/std/convert/trait.From.html +// Execute `rustlings hint from_into` or use the `hint` watch subcommand for a hint. + #[derive(Debug)] struct Person { name: String, 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::()` // 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` 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; diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index b8ec445..09f730e 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -3,6 +3,8 @@ // Basically, this is the same as From. The main difference is that this should return a Result type // instead of the target type itself. // You can read more about it at https://doc.rust-lang.org/std/convert/trait.TryFrom.html +// Execute `rustlings hint from_str` or use the `hint` watch subcommand for a hint. + use std::convert::{TryFrom, TryInto}; #[derive(Debug, PartialEq)] diff --git a/exercises/conversions/using_as.rs b/exercises/conversions/using_as.rs index f3f745f..8c9b711 100644 --- a/exercises/conversions/using_as.rs +++ b/exercises/conversions/using_as.rs @@ -4,6 +4,7 @@ // // The goal is to make sure that the division does not fail to compile // and returns the proper type. +// Execute `rustlings hint using_as` or use the `hint` watch subcommand for a hint. // I AM NOT DONE