@@ -4,32 +4,41 @@ use crate::simd::{
44} ;
55
66/// Parallel `PartialEq`.
7- pub trait SimdPartialEq < T , const N : usize >
8- where
9- T : SimdElement ,
10- {
7+ pub trait SimdPartialEq : SimdElement {
118 /// Test if each element is equal to the corresponding element in `other`.
129 #[ must_use = "method returns a new mask and does not mutate the original value" ]
13- fn simd_eq ( self , other : Self ) -> Mask < <T as SimdElement >:: Mask , N > ;
10+ fn simd_eq < const N : usize > (
11+ self : Simd < Self , N > ,
12+ other : Simd < Self , N > ,
13+ ) -> Mask < <Self as SimdElement >:: Mask , N > ;
1414
1515 /// Test if each element is not equal to the corresponding element in `other`.
1616 #[ must_use = "method returns a new mask and does not mutate the original value" ]
17- fn simd_ne ( self , other : Self ) -> Mask < <T as SimdElement >:: Mask , N > ;
17+ fn simd_ne < const N : usize > (
18+ self : Simd < Self , N > ,
19+ other : Simd < Self , N > ,
20+ ) -> Mask < <Self as SimdElement >:: Mask , N > ;
1821}
1922
2023macro_rules! impl_number {
2124 { $( $number: ty) ,* } => {
2225 $(
23- impl < const N : usize > SimdPartialEq <$number , N > for Simd < $number, N > {
26+ impl SimdPartialEq for $number {
2427 #[ inline]
25- fn simd_eq( self , other: Self ) -> Mask <<$number as SimdElement >:: Mask , N > {
28+ fn simd_eq<const N : usize >(
29+ self : Simd <Self , N >,
30+ other: Simd <Self , N >,
31+ ) -> Mask <<Self as SimdElement >:: Mask , N > {
2632 // Safety: `self` is a vector, and the result of the comparison
2733 // is always a valid mask.
2834 unsafe { Mask :: from_simd_unchecked( core:: intrinsics:: simd:: simd_eq( self , other) ) }
2935 }
3036
3137 #[ inline]
32- fn simd_ne( self , other: Self ) -> Mask <<$number as SimdElement >:: Mask , N > {
38+ fn simd_ne<const N : usize >(
39+ self : Simd <Self , N >,
40+ other: Simd <Self , N >,
41+ ) -> Mask <<Self as SimdElement >:: Mask , N > {
3342 // Safety: `self` is a vector, and the result of the comparison
3443 // is always a valid mask.
3544 unsafe { Mask :: from_simd_unchecked( core:: intrinsics:: simd:: simd_ne( self , other) ) }
@@ -41,50 +50,26 @@ macro_rules! impl_number {
4150
4251impl_number ! { f16, f32 , f64 , u8 , u16 , u32 , u64 , usize , i8 , i16 , i32 , i64 , isize }
4352
44- macro_rules! impl_mask {
45- { $( $integer: ty) ,* } => {
46- $(
47- impl <const N : usize > SimdPartialEq <$integer, N > for Mask <$integer, N > {
48- #[ inline]
49- fn simd_eq( self , other: Self ) -> Mask <<$integer as SimdElement >:: Mask , N > {
50- // Safety: `self` is a vector, and the result of the comparison
51- // is always a valid mask.
52- unsafe { Self :: from_simd_unchecked( core:: intrinsics:: simd:: simd_eq( self . to_simd( ) , other. to_simd( ) ) ) }
53- }
54-
55- #[ inline]
56- fn simd_ne( self , other: Self ) -> Mask <<$integer as SimdElement >:: Mask , N > {
57- // Safety: `self` is a vector, and the result of the comparison
58- // is always a valid mask.
59- unsafe { Self :: from_simd_unchecked( core:: intrinsics:: simd:: simd_ne( self . to_simd( ) , other. to_simd( ) ) ) }
60- }
61- }
62- ) *
63- }
64- }
65-
66- impl_mask ! { i8 , i16 , i32 , i64 , isize }
67-
68- impl < T , const N : usize > SimdPartialEq < * const T , N > for Simd < * const T , N > {
53+ impl < T > SimdPartialEq for * const T {
6954 #[ inline]
70- fn simd_eq ( self , other : Self ) -> Mask < isize , N > {
55+ fn simd_eq < const N : usize > ( self : Simd < Self , N > , other : Simd < Self , N > ) -> Mask < isize , N > {
7156 self . addr ( ) . simd_eq ( other. addr ( ) )
7257 }
7358
7459 #[ inline]
75- fn simd_ne ( self , other : Self ) -> Mask < isize , N > {
60+ fn simd_ne < const N : usize > ( self : Simd < Self , N > , other : Simd < Self , N > ) -> Mask < isize , N > {
7661 self . addr ( ) . simd_ne ( other. addr ( ) )
7762 }
7863}
7964
80- impl < T , const N : usize > SimdPartialEq < * mut T , N > for Simd < * mut T , N > {
65+ impl < T > SimdPartialEq for * mut T {
8166 #[ inline]
82- fn simd_eq ( self , other : Self ) -> Mask < isize , N > {
67+ fn simd_eq < const N : usize > ( self : Simd < Self , N > , other : Simd < Self , N > ) -> Mask < isize , N > {
8368 self . addr ( ) . simd_eq ( other. addr ( ) )
8469 }
8570
8671 #[ inline]
87- fn simd_ne ( self , other : Self ) -> Mask < isize , N > {
72+ fn simd_ne < const N : usize > ( self : Simd < Self , N > , other : Simd < Self , N > ) -> Mask < isize , N > {
8873 self . addr ( ) . simd_ne ( other. addr ( ) )
8974 }
9075}
0 commit comments