@@ -2,8 +2,8 @@ use crate::{Choice, CtAssign, CtAssignSlice};
22use core:: {
33 cmp,
44 num:: {
5- NonZeroI8 , NonZeroI16 , NonZeroI32 , NonZeroI64 , NonZeroI128 , NonZeroU8 , NonZeroU16 ,
6- NonZeroU32 , NonZeroU64 , NonZeroU128 ,
5+ NonZeroI8 , NonZeroI16 , NonZeroI32 , NonZeroI64 , NonZeroI128 , NonZeroIsize , NonZeroU8 ,
6+ NonZeroU16 , NonZeroU32 , NonZeroU64 , NonZeroU128 , NonZeroUsize ,
77 } ,
88} ;
99
@@ -15,8 +15,8 @@ use crate::CtOption;
1515/// This crate provides built-in implementations for the following types:
1616/// - [`i8`], [`i16`], [`i32`], [`i64`], [`i128`], [`isize`]
1717/// - [`u8`], [`u16`], [`u32`], [`u64`], [`u128`], [`usize`]
18- /// - [`NonZeroI8`], [`NonZeroI16`], [`NonZeroI32`], [`NonZeroI64`], [`NonZeroI128`]
19- /// - [`NonZeroU8`], [`NonZeroU16`], [`NonZeroU32`], [`NonZeroU64`], [`NonZeroU128`]
18+ /// - [`NonZeroI8`], [`NonZeroI16`], [`NonZeroI32`], [`NonZeroI64`], [`NonZeroI128`], [`NonZeroI128`]
19+ /// - [`NonZeroU8`], [`NonZeroU16`], [`NonZeroU32`], [`NonZeroU64`], [`NonZeroU128`],, [`NonZeroUsize`]
2020/// - [`cmp::Ordering`]
2121/// - [`Choice`]
2222/// - `[T; N]` where `T` impls [`CtSelectArray`], which the previously mentioned types all do,
@@ -109,11 +109,13 @@ impl_ct_select_with_ct_assign!(
109109 NonZeroI32 ,
110110 NonZeroI64 ,
111111 NonZeroI128 ,
112+ NonZeroIsize ,
112113 NonZeroU8 ,
113114 NonZeroU16 ,
114115 NonZeroU32 ,
115116 NonZeroU64 ,
116117 NonZeroU128 ,
118+ NonZeroUsize ,
117119 cmp:: Ordering
118120) ;
119121
@@ -159,7 +161,7 @@ mod alloc {
159161mod tests {
160162 use super :: { Choice , CtSelect , cmp} ;
161163
162- macro_rules! ct_select_test {
164+ macro_rules! ct_select_test_unsigned {
163165 ( $ty: ty, $name: ident) => {
164166 #[ test]
165167 fn $name( ) {
@@ -171,11 +173,31 @@ mod tests {
171173 } ;
172174 }
173175
174- ct_select_test ! ( u8 , u8_ct_select) ;
175- ct_select_test ! ( u16 , u16_ct_select) ;
176- ct_select_test ! ( u32 , u32_ct_select) ;
177- ct_select_test ! ( u64 , u64_ct_select) ;
178- ct_select_test ! ( u128 , u128_ct_select) ;
176+ macro_rules! ct_select_test_signed {
177+ ( $ty: ty, $name: ident) => {
178+ #[ test]
179+ fn $name( ) {
180+ let a: $ty = 1 ;
181+ let b: $ty = -2 ;
182+ assert_eq!( a. ct_select( & b, Choice :: FALSE ) , a) ;
183+ assert_eq!( a. ct_select( & b, Choice :: TRUE ) , b) ;
184+ }
185+ } ;
186+ }
187+
188+ ct_select_test_unsigned ! ( u8 , u8_ct_select) ;
189+ ct_select_test_unsigned ! ( u16 , u16_ct_select) ;
190+ ct_select_test_unsigned ! ( u32 , u32_ct_select) ;
191+ ct_select_test_unsigned ! ( u64 , u64_ct_select) ;
192+ ct_select_test_unsigned ! ( u128 , u128_ct_select) ;
193+ ct_select_test_unsigned ! ( usize , usize_ct_select) ;
194+
195+ ct_select_test_signed ! ( i8 , i8_ct_select) ;
196+ ct_select_test_signed ! ( i16 , i16_ct_select) ;
197+ ct_select_test_signed ! ( i32 , i32_ct_select) ;
198+ ct_select_test_signed ! ( i64 , i64_ct_select) ;
199+ ct_select_test_signed ! ( i128 , i128_ct_select) ;
200+ ct_select_test_signed ! ( isize , isize_ct_select) ;
179201
180202 #[ test]
181203 fn ordering_ct_select ( ) {
0 commit comments