FromStr vs. TryFrom #182
Replies: 5 comments
-
|
Beta Was this translation helpful? Give feedback.
-
TryFrom is queued up for stabilization in 1.34, so it might be time to start thinking about when to implement the two traits. In my opinion, I think it'd be okay to have both, and possibly implement one in terms of the other. |
Beta Was this translation helpful? Give feedback.
-
I think it would be best to implement both. API wise it doesn't matter which is implemented in terms of the other so no recommendation is necessary there. |
Beta Was this translation helpful? Give feedback.
-
One reason to favour |
Beta Was this translation helpful? Give feedback.
-
I'd suggest that if a type implements In other words, any type that implements one of them should implement all of them. Might be done using a macro. |
Beta Was this translation helpful? Give feedback.
-
There are several issues related to this in the rust repo (#1822, #2143, #53167). The FromStr and TryFrom traits are very similar. Which should a library implement?
Beta Was this translation helpful? Give feedback.
All reactions