When working with the Serde crate in Rust I tried to add a #[serde(try_from = String)]
container attribute to a type that implements FromStr
and thus can be parsed from string. Unfortunately this seems not enough for Serde, from the compiler error message it becomes obvious that I have to manually implement TryFrom<String>
, too.
Why is TryFrom<String>
not implemented automatically for all types that implement FromStr
? And why is there a separate trait for fallible conversion from strings? What is the difference between these two traits?