Makes sense, I’ve removed these. FWIW in stdsimd these traits are safe.
@mark-i-m the trait methods are safe, so their implementation must maintain safety.
@scottmcm
Everything listed is already available in safe code via either as
as is not implementable for user-defined types. An alternative would be to provide one trait that allows using as with user-defined types.
Why not also do things like &'a i32 to &'a u32?
I just implemented the trait for the types I cared about, but the list isn’t comprehensive. Nothing prevents the addition of more implementation later. If you want to propose more, ideally, you would specify exactly for which types you want this implemented. If it makes sense I’ll edit the list.
This like:
impl<'a> FromBits<&'a i32> for &'a u32 { }
impl<'a> FromBits<&'a mut i32> for &'a mut u32 { }
sound good to me.
@jmst
A much more general design seems to have an auto trait that signals that all bits pattern are valid for a data type
These traits support cases for which not all bit-patterns are valid, like the reference above (a null reference would be invalid). In any case, I don’t think I fully understand what you proposed, so maybe you could reformulate it in a different way? AFAICT you propose a trait that says whether transmuting into [u8; size_of::<T>()] is safe, and therefore, all types for which this is safe, can be safely transmuted into one another. But I am not sure if this is what I meant.
@zackw I will add some examples of this for the RFC. This is a part of the portable SIMD rfc that’s not written yet, so I couldn’t just copy it over here.