Skip to content

Commit 5eb82c2

Browse files
RustyYatognzlbg
authored andcommitted
Implement the sealed trait pattern from #258
This implements the solution proposed in #258 to allow generic usage of `Simd<T>` without comprimising the safety of `Simd<T>`.
1 parent 4bd93d9 commit 5eb82c2

File tree

6 files changed

+125
-268
lines changed

6 files changed

+125
-268
lines changed

src/codegen.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ macro_rules! impl_simd_array {
1616
pub struct $tuple_id($(crate $elem_tys),*);
1717
//^^^^^^^ leaked through SimdArray
1818

19+
impl crate::sealed::Seal for [$elem_ty; $elem_count] {}
20+
1921
impl crate::sealed::SimdArray for [$elem_ty; $elem_count] {
2022
type Tuple = $tuple_id;
2123
type T = $elem_ty;
2224
const N: usize = $elem_count;
2325
type NT = [u32; $elem_count];
2426
}
2527

28+
impl crate::sealed::Seal for $tuple_id {}
2629
impl crate::sealed::Simd for $tuple_id {
2730
type Element = $elem_ty;
2831
const LANES: usize = $elem_count;

0 commit comments

Comments
 (0)