Add missing type bounds

This commit is contained in:
Caleb Zulawski 2021-02-13 00:49:51 -05:00
parent 6362540f11
commit 16904ebfc7
14 changed files with 49 additions and 14 deletions

View file

@ -2,7 +2,10 @@ macro_rules! implement {
{
$type:ident, $int_type:ident
} => {
impl<const LANES: usize> crate::$type<LANES> {
impl<const LANES: usize> crate::$type<LANES>
where
Self: crate::LanesAtMost64,
{
/// Returns the largest integer less than or equal to each lane.
#[must_use = "method returns a new vector and does not mutate the original value"]
#[inline]
@ -16,7 +19,13 @@ macro_rules! implement {
pub fn ceil(self) -> Self {
unsafe { crate::intrinsics::simd_ceil(self) }
}
}
impl<const LANES: usize> crate::$type<LANES>
where
Self: crate::LanesAtMost64,
crate::$int_type<LANES>: crate::LanesAtMost64,
{
/// Rounds toward zero and converts to the same-width integer type, assuming that
/// the value is finite and fits in that type.
///

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `f32` values.
#[repr(simd)]
pub struct SimdF32<const LANES: usize>([f32; LANES]);
pub struct SimdF32<const LANES: usize>([f32; LANES])
where
Self: crate::LanesAtMost64;
impl_float_vector! { SimdF32, f32, SimdU32 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `f64` values.
#[repr(simd)]
pub struct SimdF64<const LANES: usize>([f64; LANES]);
pub struct SimdF64<const LANES: usize>([f64; LANES])
where
Self: crate::LanesAtMost64;
impl_float_vector! { SimdF64, f64, SimdU64 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `i128` values.
#[repr(simd)]
pub struct SimdI128<const LANES: usize>([i128; LANES]);
pub struct SimdI128<const LANES: usize>([i128; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdI128, i128 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `i16` values.
#[repr(simd)]
pub struct SimdI16<const LANES: usize>([i16; LANES]);
pub struct SimdI16<const LANES: usize>([i16; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdI16, i16 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `i32` values.
#[repr(simd)]
pub struct SimdI32<const LANES: usize>([i32; LANES]);
pub struct SimdI32<const LANES: usize>([i32; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdI32, i32 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `i64` values.
#[repr(simd)]
pub struct SimdI64<const LANES: usize>([i64; LANES]);
pub struct SimdI64<const LANES: usize>([i64; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdI64, i64 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `i8` values.
#[repr(simd)]
pub struct SimdI8<const LANES: usize>([i8; LANES]);
pub struct SimdI8<const LANES: usize>([i8; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdI8, i8 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `isize` values.
#[repr(simd)]
pub struct SimdIsize<const LANES: usize>([isize; LANES]);
pub struct SimdIsize<const LANES: usize>([isize; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdIsize, isize }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `u128` values.
#[repr(simd)]
pub struct SimdU128<const LANES: usize>([u128; LANES]);
pub struct SimdU128<const LANES: usize>([u128; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdU128, u128 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `u16` values.
#[repr(simd)]
pub struct SimdU16<const LANES: usize>([u16; LANES]);
pub struct SimdU16<const LANES: usize>([u16; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdU16, u16 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `u32` values.
#[repr(simd)]
pub struct SimdU32<const LANES: usize>([u32; LANES]);
pub struct SimdU32<const LANES: usize>([u32; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdU32, u32 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `u64` values.
#[repr(simd)]
pub struct SimdU64<const LANES: usize>([u64; LANES]);
pub struct SimdU64<const LANES: usize>([u64; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdU64, u64 }

View file

@ -2,7 +2,9 @@
/// A SIMD vector of containing `LANES` `usize` values.
#[repr(simd)]
pub struct SimdUsize<const LANES: usize>([usize; LANES]);
pub struct SimdUsize<const LANES: usize>([usize; LANES])
where
Self: crate::LanesAtMost64;
impl_integer_vector! { SimdUsize, usize }