rust-lang / packed_simd

Portable Packed SIMD Vectors for Rust standard library
https://rust-lang.github.io/packed_simd/packed_simd_2/
Apache License 2.0
600 stars 74 forks source link

Implement the sealed trait pattern #259

Closed RustyYato closed 5 years ago

RustyYato commented 5 years ago

This implements #258 and safely exposes all the traits inside of the sealed module without allowing outside implementations of these traits. This allows them the be used as generic bounds.

gnzlbg commented 5 years ago

Thanks, I think that originally we only wanted the concrete types to be used (e.g. f32x4) since we did not know what the stability story for Simd<T> would be, but that's changing now with const generics, so I think we should just do this.

novacrazy commented 5 years ago

When could we expect this to be published?

gnzlbg commented 5 years ago

I can do a release once CI is green again.

burrbull commented 5 years ago

What about implementing of these traits for primitive types? Like:

impl crate::sealed::Simd for f32 {
    type Element = f32;
    const LANES: usize =1;
    type LanesType = f32;
}

This could be useful for api generic for both simd and primitive types?

gnzlbg commented 5 years ago

This could be useful for api generic for both simd and primitive types?

Since f32 is not a proper argument for Simd<T> I don't know how this could work.