Skip to content

Commit

Permalink
Let widen() officially support equal bit-widths as (due a bug) this w…
Browse files Browse the repository at this point in the history
…as already allowed. (#25)

While at it, remove SMALLER_THAN as the old definition is broken. We don't need it right now.
  • Loading branch information
danlehmann authored May 26, 2023
1 parent bde2501 commit 69ea2d5
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ impl<const A: usize, const B: usize> CompileTimeAssert<A, B> {
pub const SMALLER_OR_EQUAL: () = {
assert!(A <= B);
};
pub const SMALLER_THAN: () = {
assert!(A <= B);
};
}

#[derive(Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd)]
Expand Down Expand Up @@ -328,7 +325,7 @@ macro_rules! uint_impl {
pub const fn widen<const BITS_RESULT: usize>(
self,
) -> UInt<$type, BITS_RESULT> {
let _ = CompileTimeAssert::<BITS, BITS_RESULT>::SMALLER_THAN;
let _ = CompileTimeAssert::<BITS, BITS_RESULT>::SMALLER_OR_EQUAL;
// Query MAX of the result to ensure we get a compiler error if the current definition is bogus (e.g. <u8, 9>)
let _ = UInt::<$type, BITS_RESULT>::MAX;
UInt::<$type, BITS_RESULT> { value: self.value }
Expand Down

0 comments on commit 69ea2d5

Please sign in to comment.