Skip to content

Commit

Permalink
Add missing type bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
calebzulawski committed Feb 13, 2021
1 parent 6362540 commit 16904eb
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 14 deletions.
11 changes: 10 additions & 1 deletion crates/core_simd/src/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.
///
Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_i128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_i16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_i32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_i64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_i8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_isize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_u128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_u16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 3 additions & 1 deletion crates/core_simd/src/vectors_usize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit 16904eb

Please sign in to comment.