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

use crate::mask::MaskElement;

use core::error::Error;
use core::fmt::{self, Debug, Display, Formatter};

/// An integral SIMD vector could not be converted to a mask.
#[derive(Clone, Debug)]
pub struct MaskTryFromIntError<T: MaskElement> {
	/// The index of the invalid integer.
	pub index: usize,

	/// The value of the invalid integer.
	pub value: T,
}

impl<T: MaskElement + Display> Display for MaskTryFromIntError<T> {
	#[inline]
	fn fmt(&self, f: &mut Formatter) -> fmt::Result {
		write!(
			f,
			"cannot construct simd mask from vector with value `{}` at `{}`",
			self.value,
			self.index,
		)
	}
}

impl<T: MaskElement + Debug + Display> Error for MaskTryFromIntError<T> { }