Skip to content

Commit 6b9986b

Browse files
Hack in a pseudo inherent associated type
1 parent b8d6b68 commit 6b9986b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

crates/core_simd/src/vector.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,3 +526,31 @@ impl Sealed for f64 {}
526526
unsafe impl SimdElement for f64 {
527527
type Mask = i64;
528528
}
529+
530+
impl<T, const LANES: usize> Sealed for Simd<T, LANES>
531+
where
532+
T: SimdElement,
533+
LaneCount<LANES>: SupportedLaneCount,
534+
{
535+
}
536+
537+
// FIXME(jubilee): This is a brutal hack for an "inherent associated type".
538+
// It's not that bad, really, but neither is it necessary per se.
539+
540+
/// A trait describing a vector's associated scalar type.
541+
/// This is just a hack around inherent associated types requiring lazy norm.
542+
#[doc(hidden)]
543+
pub trait Vector: Sealed {
544+
/// A vector's associated scalar type.
545+
#[doc(hidden)]
546+
type Scalar: SimdElement;
547+
}
548+
549+
#[doc(hidden)]
550+
impl<T, const LANES: usize> Vector for Simd<T, LANES>
551+
where
552+
T: SimdElement,
553+
LaneCount<LANES>: SupportedLaneCount,
554+
{
555+
type Scalar = T;
556+
}

0 commit comments

Comments
 (0)