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

/// Denotes a SIMD data kind.
///
/// Each SIMD scalar type has its own data kind -- as denoted by this enumeration.
#[derive(
	Clone,
	Copy,
	Debug,
	Eq,
	PartialEq,
)]
pub enum DataKind {
	/// The [`u8`] type.
	U8,

	/// The [`i8`] type.
	I8,

	/// The [`u16`] type.
	U16,

	/// The [`i16`] type.
	I16,

	/// The [`u32`] type.
	U32,

	/// The [`i32`] type.
	I32,

	/// The [`u64`] type.
	U64,

	/// The [`i64`] type.
	I64,

	/// The [`u128`] type.
	U128,

	/// The [`i128`] type.
	I128,

	/// The [`usize`] type.
	Usize,

	/// The [`isize`] type.
	Isize,

	/// The [`f16`] type.
	#[cfg(feature = "f16")]
	F16,

	/// The [`f32`] type.
	F32,

	/// The [`f64`] type.
	F64,

	/// The [`f128`] type.
	#[cfg(feature = "f128")]
	F128,

	#[cfg_attr(feature = "unstable_docs",      doc = "Any [`*const _`](pointer) type.")]
	#[cfg_attr(not(feature = "unstable_docs"), doc = "Any `*const _` type.")]
	ConstPtr,

	#[cfg_attr(feature = "unstable_docs",      doc = "Any [`*mut _`](pointer) type.")]
	#[cfg_attr(not(feature = "unstable_docs"), doc = "Any `*mut _` type.")]
	MutPtr,
}

impl DataKind {
	/// Tests if data kind is size-like, i.e. has a representation based on [`usize`].
	#[inline(always)]
	#[must_use]
	pub const fn is_size_like(self) -> bool {
		matches!(
			self,
			| Self::Usize
			| Self::Isize
			| Self::ConstPtr
			| Self::MutPtr,
		)
	}
}