@@ -14,7 +14,7 @@ pub(crate) mod neon;
1414pub ( crate ) mod scalar;
1515
1616impl < ' a , const NB : usize , T : Copy > Filter < BitView < ' a , NB > > for & mut [ T ] {
17- type Output = ( ) ;
17+ type Output = Self ;
1818
1919 fn filter ( self , mask : & BitView < ' a , NB > ) -> Self :: Output {
2020 #[ cfg( target_arch = "aarch64" ) ]
@@ -24,21 +24,25 @@ impl<'a, const NB: usize, T: Copy> Filter<BitView<'a, NB>> for &mut [T] {
2424 match size_of :: < T > ( ) {
2525 1 | 2 if mask. true_count ( ) < ( BitView :: < NB > :: N / 4 ) => {
2626 // For u8 and u16, the threshold is ~0.25
27- return scalar:: filter_scalar ( self , mask) ;
27+ scalar:: filter_scalar ( self , mask) ;
28+ return & mut self [ ..mask. true_count ( ) ] ;
2829 }
2930 4 if mask. true_count ( ) < ( 3 * BitView :: < NB > :: N / 4 ) => {
3031 // For u32, the threshold is ~0.75
31- return scalar:: filter_scalar ( self , mask) ;
32+ scalar:: filter_scalar ( self , mask) ;
33+ return & mut self [ ..mask. true_count ( ) ] ;
3234 }
3335 _ => { }
3436 }
3537
36- return unsafe { neon:: filter_neon ( self , mask) } ;
38+ unsafe { neon:: filter_neon ( self , mask) }
39+ return & mut self [ ..mask. true_count ( ) ] ;
3740 }
3841 }
3942
4043 // Otherwise, fall back to scalar implementation
4144 scalar:: filter_scalar ( self , mask) ;
45+ & mut self [ ..mask. true_count ( ) ]
4246 }
4347}
4448
0 commit comments