Merge pull request #358 from windexlight/scalar-u32x2-fix

Implement BitAnd, BitOr, and Not for U32x2 in scalar version.
This commit is contained in:
Patrick Walton 2020-06-16 08:37:02 -07:00 committed by GitHub
commit a47c703518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 1 deletions

View File

@ -10,7 +10,7 @@
use std::f32; use std::f32;
use std::fmt::{self, Debug, Formatter}; use std::fmt::{self, Debug, Formatter};
use std::ops::{Add, BitAnd, BitOr, Div, Index, IndexMut, Mul, Shr, Sub}; use std::ops::{Add, BitAnd, BitOr, Div, Index, IndexMut, Mul, Shr, Sub, Not};
mod swizzle_f32x4; mod swizzle_f32x4;
mod swizzle_i32x4; mod swizzle_i32x4;
@ -840,6 +840,31 @@ impl U32x2 {
pub fn to_i32x2(self) -> I32x2 { pub fn to_i32x2(self) -> I32x2 {
I32x2::new(self[0] as i32, self[1] as i32) I32x2::new(self[0] as i32, self[1] as i32)
} }
}
impl BitAnd<U32x2> for U32x2 {
type Output = U32x2;
#[inline]
fn bitand(self, other: U32x2) -> U32x2 {
U32x2([self[0] & other[0], self[1] & other[1]])
}
}
impl BitOr<U32x2> for U32x2 {
type Output = U32x2;
#[inline]
fn bitor(self, other: U32x2) -> U32x2 {
U32x2([self[0] | other[0], self[1] | other[1]])
}
}
impl Not for U32x2 {
type Output = U32x2;
#[inline]
fn not(self) -> U32x2 {
U32x2([!self[0], !self[1]])
}
} }
impl Index<usize> for U32x2 { impl Index<usize> for U32x2 {