Skip to content

Commit

Permalink
cmov: fix size_of warning on Rust 1.80 (#1089)
Browse files Browse the repository at this point in the history
`size_of` is now in the prelude, so on older versions it needs to be
imported explicitly.
  • Loading branch information
tarcieri authored Jul 26, 2024
1 parent 3867a73 commit a997e3f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmov/src/portable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// TODO(tarcieri): more optimized implementation for small integers

use crate::{Cmov, CmovEq, Condition};
use core::mem::size_of;

impl Cmov for u16 {
#[inline]
Expand Down Expand Up @@ -97,7 +98,7 @@ impl CmovEq for u64 {
/// - `condition` is non-zero: `1`
#[inline]
fn is_non_zero(condition: Condition) -> u64 {
const SHIFT_BITS: usize = core::mem::size_of::<u64>() - 1;
const SHIFT_BITS: usize = size_of::<u64>() - 1;
let condition = condition as u64;
((condition | (!condition).wrapping_add(1)) >> SHIFT_BITS) & 1
}

0 comments on commit a997e3f

Please sign in to comment.