rust-ux / uX

Non standard integer types like `u7`, `u9`, `u10`, `u63`, `i7`, `i9`
Apache License 2.0
121 stars 37 forks source link

Support Into/From/TryInto/TryFrom usize #43

Closed bbaldino closed 2 years ago

bbaldino commented 2 years ago

I was trying to convert a ux type to usize and saw that it wasn't implemented, is that intentional perhaps due to its lack of a fixed size? I was thinking at least TryInto/TryFrom usize would make sense.

kjetilkjeka commented 2 years ago

I agree that TryFrom/TryInto should be implemented. This is also what stdlib does. Thanks for pointing this out. I will gladly merge a PR that adds these implementations as long as it covers all types.

I think stdlib avoids implementing From/Into conversions for usize/isize to ensure portability between platforms of all address sizes. I think it's best to follow std here as well.

bbaldino commented 2 years ago

Cool, I'll take a shot at that.

bbaldino commented 2 years ago

Opened https://github.com/kjetilkjeka/uX/pull/44