A suggestion for try_from

In the part of my code that works with unstable features I use few thousands of times code like (I call those through a small macro to shorten them):

usize::try_from(u64).unwrap()
usize::try_from(u32).unwrap()
32::try_from(usize).unwrap()

That broke in the last Nigthly (https://github.com/rust-lang/rust/pull/49305#issuecomment-376293243 ). What do you suggest me to do?

Can you modify your macro to do cast based conversion, with appropriate bounds guards?

Yes, replacing the macro with another one using a cast seems the simplest solution. But I am not sure how to perform the appropriate bounds guards for all the cases it’s used (usize <-> u32, usize <-> u64, 32 <-> u64, etc). I should re-implement a generic try_from.

Can you do what the old/removed impls did?