rust-ux / uX

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

Adding BITS constants to match inbox primitive types. #55

Closed r12f closed 4 months ago

r12f commented 1 year ago

Since 1.53.0, rust added the new constant BITS with type as u32, so it might be helpful to add it in uX crate as well for writing uniformed code.

Should be a straight-forward change, hence I have forked the repo and created a branch here: https://github.com/r12f/uX/tree/add-bits. Please let me know, how it looks! And if it makes sense to you, I can send out the PR for update.

JonathanWoollett-Light commented 1 year ago

If you're interested, check out my overhaul project https://github.com/JonathanWoollett-Light/ux2 where this is implemented e.g. https://docs.rs/ux2/latest/ux2/struct.i10.html#associatedconstant.BITS.

bbaldino commented 4 months ago

@r12f (or @JonathanWoollett-Light) this makes sense to me and if you want to open a PR for this I'll review it. If not I'll probably take a look at adding it myself soon--I've needed this in a lib of mine that uses uX as well and ended up writing an extension trait for it, would be nice to have it in the lib.