Manually implement some traits, instead of derive
This commit is contained in:
@@ -138,6 +138,32 @@ macro_rules! call_counting_args {
|
|||||||
/// Implements common traits on the specified vector `$name`, holding multiple `$lanes` of `$type`.
|
/// Implements common traits on the specified vector `$name`, holding multiple `$lanes` of `$type`.
|
||||||
macro_rules! base_vector_traits {
|
macro_rules! base_vector_traits {
|
||||||
{ $name:path => [$type:ty; $lanes:literal] } => {
|
{ $name:path => [$type:ty; $lanes:literal] } => {
|
||||||
|
impl Copy for $name {}
|
||||||
|
|
||||||
|
impl Clone for $name {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
*self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for $name {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::splat(<$type>::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for $name {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
AsRef::<[$type]>::as_ref(self) == AsRef::<[$type]>::as_ref(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for $name {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
|
||||||
|
AsRef::<[$type]>::as_ref(self).partial_cmp(AsRef::<[$type]>::as_ref(other))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// array references
|
// array references
|
||||||
impl AsRef<[$type; $lanes]> for $name {
|
impl AsRef<[$type; $lanes]> for $name {
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -196,7 +222,6 @@ macro_rules! define_vector {
|
|||||||
{ def $(#[$attr:meta])* | $name:ident | $($itype:ty)* } => {
|
{ def $(#[$attr:meta])* | $name:ident | $($itype:ty)* } => {
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Copy, Clone, Default, PartialEq, PartialOrd)]
|
|
||||||
#[repr(simd)]
|
#[repr(simd)]
|
||||||
pub struct $name($($itype),*);
|
pub struct $name($($itype),*);
|
||||||
};
|
};
|
||||||
@@ -233,7 +258,7 @@ macro_rules! define_mask_vector {
|
|||||||
{ def $(#[$attr:meta])* | $name:ident | $($itype:ty)* } => {
|
{ def $(#[$attr:meta])* | $name:ident | $($itype:ty)* } => {
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Copy, Clone, Default, PartialEq, PartialOrd, Eq, Ord)]
|
#[derive(Eq, Ord)]
|
||||||
#[repr(simd)]
|
#[repr(simd)]
|
||||||
pub struct $name($($itype),*);
|
pub struct $name($($itype),*);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user