danlehmann / arbitrary-int

A modern and lightweight implementation of arbitrary integers for Rust
MIT License
31 stars 12 forks source link

possible typo in `CompileTimeAssert::SMALLER_THAN` #24

Closed pickx closed 1 year ago

pickx commented 1 year ago

both CompileTimeAssert::SMALLER_THAN_EQUAL and CompileTimeAssert::SMALLER_THAN assert that A <= B.

hopefully I didn't miss something obvious, but I'd expect SMALLER_THAN to assert that A < B.

danlehmann commented 1 year ago

Hey, nice find! Luckily, not much is broken in practice. The only result is that the following call is possible:

let a: u7 = u7::new(1).widen()

Which is - while pointless - also fine.

I'll upload a patch to make widen officially support equal bitlengths and remove the SMALLER_THAN check. This way if anyone's using the current behavior (e.g. in autogenerated code) things will work as before.