Skip to content

Commit df58872

Browse files
committed
Add assertion checking that a u8 bool is valid
1 parent 4978f42 commit df58872

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ impl Not for Choice {
203203
impl From<u8> for Choice {
204204
#[inline]
205205
fn from(input: u8) -> Choice {
206+
debug_assert!((input == 0u8) | (input == 1u8));
206207
// Our goal is to prevent the compiler from inferring that the value held inside the
207208
// resulting `Choice` struct is really an `i1` instead of an `i8`.
208209
Choice(core::hint::black_box(input))

0 commit comments

Comments
 (0)