So I like your approach a lot. Declaring all FromBits/IntoBits
implementation in stdsimd
is painful and error prone (as in, it is easy to miss one). With your approach we would still need to declare some of them manually, but due to transitivity we would get most of them for free.
For example, we would only need to implement the traits for most portable vector types only once, e.g., from u8x16
to __m128
and viceversa, and because of transitivity, we get the u16x8
, u32x4
, i32x4
, f32x4
, … conversions automatically for free.
For the vector mask types like b8x16
, we can implement b8x16 -> __m128
but not the other way around, and get all the correct conversions for free.
With FromBits/IntoBits
one needs N^2
implementations, with your approach 1 for types with public fields which the compiler fills in for you, and at worst O(N)
for types that should only support uni-directional conversions.
I think it would be really nice if you could write an RFC, and if you need help with the motivation or examples we have more than enough in stdsimd
.