midly
midly copied to clipboard
Consider using the bounded_integer crate
Hi @kovaxis! This is more of a suggestion than anything else: maybe there is interest in reducing the technical debt of maintaining u7
, u4
, etc. and use some purpose-built solution? I've checked the available crates and bounded_integer seemed interesting and used enough to be considered?
cc. @gbrochar you've currently involved in something related in #26 and #27, aren't you?
Hey, I can only agree, I had thought of that but didn't look for existing solutions. I'm done to do more research and code if we find a solution that sounds reasonable. I'm starting my first big project in rust and I would love to contribute for real in a closely related open source project.
I don't want to "bias" the library towards my needs tho and I don't know if I can avoid doing that without exterior opinion.
To be honest, the usage of u4
and u7
in this library is probably a mistake. Sure, it makes the library somewhat more type-safe, but at a the cost of usability. bounded_integer
would help, but I'd also prefer not to bring in extra dependencies for the sake of compile times.
For the next breaking change, I will drop the usage of these types and just use u8
and produce an error for out-of-bounds integers. Along with other simplifications to the API.