File tree 3 files changed +14
-8
lines changed
3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 1
1
#![ cfg_attr( not( feature = "std" ) , no_std) ]
2
2
#![ feature(
3
3
const_fn_trait_bound,
4
+ convert_float_to_int,
4
5
decl_macro,
5
6
platform_intrinsics,
6
7
repr_simd,
Original file line number Diff line number Diff line change 1
1
use crate :: simd:: intrinsics;
2
- use crate :: simd:: { LaneCount , Simd , SupportedLaneCount } ;
2
+ use crate :: simd:: { LaneCount , Simd , SimdElement , SupportedLaneCount } ;
3
+ use core:: convert:: FloatToInt ;
3
4
4
5
macro_rules! implement {
5
6
{
6
- $type: ty, $int_type : ty
7
+ $type: ty
7
8
} => {
8
9
impl <const LANES : usize > Simd <$type, LANES >
9
10
where
@@ -19,12 +20,16 @@ macro_rules! implement {
19
20
/// * Not be infinite
20
21
/// * Be representable in the return type, after truncating off its fractional part
21
22
#[ inline]
22
- pub unsafe fn to_int_unchecked( self ) -> Simd <$int_type, LANES > {
23
+ pub unsafe fn to_int_unchecked<I >( self ) -> Simd <I , LANES >
24
+ where
25
+ $type: FloatToInt <I >,
26
+ I : SimdElement ,
27
+ {
23
28
unsafe { intrinsics:: simd_cast( self ) }
24
29
}
25
30
}
26
31
}
27
32
}
28
33
29
- implement ! { f32 , i32 }
30
- implement ! { f64 , i64 }
34
+ implement ! { f32 }
35
+ implement ! { f64 }
Original file line number Diff line number Diff line change @@ -64,11 +64,11 @@ macro_rules! float_rounding_test {
64
64
runner. run(
65
65
& test_helpers:: array:: UniformArrayStrategy :: new( -MAX_REPRESENTABLE_VALUE ..MAX_REPRESENTABLE_VALUE ) ,
66
66
|x| {
67
- let result_1 = unsafe { Vector :: from_array( x) . to_int_unchecked( ) . to_array( ) } ;
67
+ let result_1 = unsafe { Vector :: from_array( x) . to_int_unchecked:: < IntScalar > ( ) . to_array( ) } ;
68
68
let result_2 = {
69
- let mut result = [ 0 ; LANES ] ;
69
+ let mut result: [ IntScalar ; LANES ] = [ 0 ; LANES ] ;
70
70
for ( i, o) in x. iter( ) . zip( result. iter_mut( ) ) {
71
- * o = unsafe { i. to_int_unchecked( ) } ;
71
+ * o = unsafe { i. to_int_unchecked:: < IntScalar > ( ) } ;
72
72
}
73
73
result
74
74
} ;
You can’t perform that action at this time.
0 commit comments