Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ctutils/src/traits/ct_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ mod tests {
assert!(EXAMPLE.ct_lookup(4u32).is_none().to_bool());
}

// usize only has a `CtEq` impl on 32-bit and 64-bit targets currently
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
#[test]
fn ct_lookup_usize() {
assert_eq!(EXAMPLE.ct_lookup(0usize).unwrap(), 1);
Expand All @@ -125,8 +123,6 @@ mod tests {
assert!(EXAMPLE.ct_lookup(4u32).is_none().to_bool());
}

// usize only has a `CtEq` impl on 32-bit and 64-bit targets currently
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
#[test]
fn ct_lookup_usize() {
assert_eq!(EXAMPLE.ct_lookup(0usize).unwrap(), 1);
Expand Down
36 changes: 3 additions & 33 deletions ctutils/src/traits/ct_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ macro_rules! impl_ct_select_with_ct_assign {
};
}

impl_ct_select_with_ct_assign!(i8, i16, i32, i64, i128, u8, u16, u32, u64, u128);
impl_ct_select_with_ct_assign!(
i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize
);

/// Impl `CtSelect` for `NonZero<T>` by calling the `CtSelect` impl for `T`.
macro_rules! impl_ct_select_for_nonzero_integer {
Expand Down Expand Up @@ -135,38 +137,6 @@ impl_ct_select_for_nonzero_integer!(
NonZeroU128
);

#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
impl CtSelect for isize {
#[cfg(target_pointer_width = "32")]
#[inline]
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
(*self as i32).ct_select(&(*other as i32), choice) as isize
}

#[cfg(target_pointer_width = "64")]
#[allow(clippy::cast_possible_truncation)]
#[inline]
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
(*self as i64).ct_select(&(*other as i64), choice) as isize
}
}

#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
impl CtSelect for usize {
#[cfg(target_pointer_width = "32")]
#[inline]
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
(*self as u32).ct_select(&(*other as u32), choice) as usize
}

#[cfg(target_pointer_width = "64")]
#[allow(clippy::cast_possible_truncation)]
#[inline]
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
(*self as u64).ct_select(&(*other as u64), choice) as usize
}
}

impl CtSelect for cmp::Ordering {
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
// `Ordering` is `#[repr(i8)]` where:
Expand Down