polylane 0.6.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 MaskElement: Copy {
		#[must_use]
		fn test(self) -> bool;
	}
}

use crate::simd::SimdElement;

pub(crate) use seal::MaskElement as SealedMaskElement;

/// Denotes a type suitable as a SIMD mask element.
///
/// Only signed, integral types may be mask elements.
pub trait MaskElement: SimdElement + SealedMaskElement { }

macro_rules! impl_mask_element {
	{
		$($Ty:ty),*$(,)?
	} => {
		$(
			impl ::polylane::mask::SealedMaskElement for $Ty {
				#[inline(always)]
				fn test(self) -> bool {
					self == 0x0
				}
			}

			impl ::polylane::mask::MaskElement for $Ty { }
		)*
	};
}

impl_mask_element! {
	i8,
	i16,
	i32,
	i64,
	i128,
	isize,
}