polylane 0.3.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/>.

mod seal {
	pub trait SimdElement { }
}

pub(crate) use seal::SimdElement as SealedSimdElement;

/// Denotes a type suitable as a SIMD vector element.
///
/// Only primitive, arithmetic types may be vector elements.
pub trait SimdElement: Copy + SealedSimdElement { }

macro_rules! impl_simd_element {
	{
		$($ty:ty),*$(,)?
	} => {
		$(
			impl ::polylane::SealedSimdElement for $ty { }

			impl ::polylane::SimdElement for $ty { }
		)*
	};
}

impl_simd_element! {
	u8,
	i8,
	u16,
	i16,
	u32,
	i32,
	u64,
	i64,
	u128,
	i128,

	f32,
	f64,
}

#[cfg(feature = "f16")]
impl_simd_element! { f16 }

#[cfg(feature = "f128")]
impl_simd_element! { f128 }