Skip to content

Commit

Permalink
Use strict evaluation of OR in debug_assert
Browse files Browse the repository at this point in the history
  • Loading branch information
brycx committed Apr 10, 2019
1 parent 558316b commit bf3888e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl From<Choice> for bool {
/// verification.
#[inline]
fn from(source: Choice) -> bool {
debug_assert!(source.0 == 0u8 || source.0 == 1u8);
debug_assert!((source.0 == 0u8) | (source.0 == 1u8));
source.0 != 0
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ impl Not for Choice {
not(any(target_arch = "asmjs", target_arch = "wasm32"))
))]
fn black_box(input: u8) -> u8 {
debug_assert!(input == 0u8 || input == 1u8);
debug_assert!((input == 0u8) | (input == 1u8));

// Pretend to access a register containing the input. We "volatile" here
// because some optimisers treat assembly templates without output operands
Expand All @@ -160,7 +160,7 @@ fn black_box(input: u8) -> u8 {
))]
#[inline(never)]
fn black_box(input: u8) -> u8 {
debug_assert!(input == 0u8 || input == 1u8);
debug_assert!((input == 0u8) | (input == 1u8));
// We don't have access to inline assembly or test::black_box or ...
//
// Bailing out, hopefully the compiler doesn't use the fact that `input` is 0 or 1.
Expand Down

0 comments on commit bf3888e

Please sign in to comment.