use std::fmt::Debug;
use crate::elem::Elem;
use crate::ops::Isa;
pub trait Mask: Copy + Debug {
type Array: AsRef<[bool]>
+ Copy
+ Debug
+ IntoIterator<Item = bool>
+ PartialEq<Self::Array>
+ std::ops::Index<usize, Output = bool>;
fn to_array(self) -> Self::Array;
}
#[allow(clippy::len_without_is_empty)]
pub trait Simd: Copy + Debug {
type Array: AsRef<[Self::Elem]>
+ Copy
+ Debug
+ IntoIterator<Item = Self::Elem>
+ PartialEq<Self::Array>
+ std::ops::Index<usize, Output = Self::Elem>
+ std::ops::IndexMut<usize, Output = Self::Elem>;
type Elem: Elem;
type Mask: Mask;
type Isa: Isa;
fn to_bits(self) -> <Self::Isa as Isa>::Bits;
fn from_bits(bits: <Self::Isa as Isa>::Bits) -> Self;
fn reinterpret_cast<T>(self) -> T
where
T: Simd<Isa = Self::Isa>,
{
T::from_bits(self.to_bits())
}
fn same_cast<T>(self) -> T
where
T: Simd<Elem = Self::Elem, Isa = Self::Isa>,
{
T::from_bits(self.to_bits())
}
fn to_array(self) -> Self::Array;
}