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?
FromStris much older andTryFromwas added only later. However, the trait autoimplementation that you expected sounds logical, maybe there were technical reasons and it could not be easily done. - Zólyomi Istvánserde_withallows you to automatically (de)serialize usingFromStrandDisplay, and has many other convenience features - trentclserde_with. I will take a look, but as my project targets WASM I'm rather sensitive to additional dependencies in case they increase output size. - blerontin