Where to request to implement FromStr for Wrapping<T: FromStr>

I ran into a problem where the following function cannot accept Wrapping types due to them not implementing FromStr even though all the types Wrapping accepts have FromStr implementations.

fn calc<T>(s: &str) -> Result<T, Error> where T: FromStr + Add<Output=T>...

I was wondering if this is a deliberate decision? If so what is the reason, I wasn't able to find any discussion. If it is just an oversight, I am happy to do the work to get this implemented and just need to be pointed in the right direction (RFC or Issue on the rust repo?).

You can just send a PR to the rust-lang/rust repo for adding simple trait impl like this.

1 Like

Note that trait impls are insta-stable, so you should expect more process and questions than for methods/types, which can go in as unstable and be tweaked over time.

One big question I would have for this: is "300".parse::<Wrapping<u8>>() supposed to give Err(_) or Ok(44)? Similarly, if we had other such wrapper types in num in the future, would "-1".parse::<Saturating<u64>>() be Ok(0)?


I was thinking that it would have the same error behavior as the wrapped type.

And while I'm not a member of any team, I would highly expect this to be a hard requirement to get merged. If any other behavior were the case, some very surprising bugs would arise.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.