@@ -85,15 +85,31 @@ pub const fn bitmask_len(lanes: usize) -> usize {
8585}
8686
8787#[ cfg( feature = "generic_const_exprs" ) ]
88- impl < T : MaskElement , const LANES : usize > ToBitMask < [ u8 ; bitmask_len ( LANES ) ] > for Mask < T , LANES >
89- where
90- LaneCount < LANES > : SupportedLaneCount ,
91- {
92- fn to_bitmask ( self ) -> [ u8 ; bitmask_len ( LANES ) ] {
93- self . 0 . to_bitmask ( )
94- }
88+ macro_rules! impl_array_bitmask {
89+ { $( impl ToBitMask <[ u8 ; _] > for Mask <_, $lanes: literal>) * } => {
90+ $(
91+ impl <T : MaskElement > ToBitMask <[ u8 ; bitmask_len( $lanes) ] > for Mask <T , $lanes>
92+ {
93+ fn to_bitmask( self ) -> [ u8 ; bitmask_len( $lanes) ] {
94+ self . 0 . to_bitmask( )
95+ }
9596
96- fn from_bitmask ( bitmask : [ u8 ; bitmask_len ( LANES ) ] ) -> Self {
97- Mask ( mask_impl:: Mask :: from_bitmask ( bitmask) )
97+ fn from_bitmask( bitmask: [ u8 ; bitmask_len( $lanes) ] ) -> Self {
98+ Mask ( mask_impl:: Mask :: from_bitmask( bitmask) )
99+ }
100+ }
101+ ) *
98102 }
99103}
104+
105+ // FIXME this should be specified generically, but it doesn't seem to work with rustc, yet
106+ #[ cfg( feature = "generic_const_exprs" ) ]
107+ impl_array_bitmask ! {
108+ impl ToBitMask <[ u8 ; _] > for Mask <_, 1 >
109+ impl ToBitMask <[ u8 ; _] > for Mask <_, 2 >
110+ impl ToBitMask <[ u8 ; _] > for Mask <_, 4 >
111+ impl ToBitMask <[ u8 ; _] > for Mask <_, 8 >
112+ impl ToBitMask <[ u8 ; _] > for Mask <_, 16 >
113+ impl ToBitMask <[ u8 ; _] > for Mask <_, 32 >
114+ impl ToBitMask <[ u8 ; _] > for Mask <_, 64 >
115+ }
0 commit comments