polylane 0.9.0

Portable and versatile SIMD.
Documentation
// Copyright 2025 Gabriel Bjørnager Jensen.
//
// This Source Code Form is subject to the terms of
// the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, you
// can obtain one at:
// <https://mozilla.org/MPL/2.0/>.

#[cfg(feature = "ptr")]
use core::ptr::Thin;

/// Denotes a type suitable as a [SIMD vector](crate::simd::Simd) element.
///
/// Only primitive, arithmetic types may be vector elements.
pub trait SimdScalar: Copy + crate::simd::seal::SimdScalar {}

macro_rules! impl_simd_scalar {
	{
		$($Ty:ty $(= $feature:literal)?),*$(,)?
	} => {
		$(
			$(#[cfg(feature = $feature)])?
			impl ::polylane::simd::seal::SimdScalar for $Ty {}

			$(#[cfg(feature = $feature)])?
			impl ::polylane::simd::SimdScalar for $Ty {}
		)*
	};
}

impl_simd_scalar! {
	u8,
	i8,
	u16,
	i16,
	u32,
	i32,
	u64,
	i64,
	u128,
	i128,
	usize,
	isize,

	f16  = "f16",
	f32,
	f64,
	f128 = "f128",
}

#[cfg(feature = "ptr")]
impl<T: Thin> crate::simd::seal::SimdScalar for *const T {}

#[cfg(feature = "ptr")] impl<T: Thin> SimdScalar for *const T {}

#[cfg(feature = "ptr")]
impl<T: Thin> crate::simd::seal::SimdScalar for *mut T {}

#[cfg(feature = "ptr")] impl<T: Thin> SimdScalar for *mut T {}