rust-ux / uX

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

Added associated constant BITS #50

Open bluecube opened 1 year ago

bluecube commented 1 year ago

This matches rust primitive types since 1.53.0, helps a bit when using this crate's types with macros.

bbaldino commented 1 year ago

I actually came into a use case that'd need something like this recently...I was wondering if it'd be nice to also introduce a trait that defined BITS, MAX, MIN and new such that it'd be easier to write generic methods for any uX type that needed to access those properties.

bluecube commented 1 year ago

it would probably be best to implement traits from num_traits. Bounded for this use case.

bbaldino commented 1 year ago

it would probably be best to implement traits from num_traits. Bounded for this use case.

Yeah that probably makes sense. Too bad there doesn't appear one that would map to BITS here though, but maybe just that could be defined in a new trait.