Skip to content

Commit

Permalink
Change mask function to accept bool
Browse files Browse the repository at this point in the history
  • Loading branch information
sammysheep committed Sep 28, 2024
1 parent c9c0bf9 commit 9392fb1
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions crates/core_simd/src/swizzle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,18 +499,30 @@ where
/// `padding` from the right.
#[inline]
#[must_use = "method returns a new mask and does not mutate the original inputs"]
pub fn shift_elements_left<const OFFSET: usize>(self, padding: T) -> Self {
pub fn shift_elements_left<const OFFSET: usize>(self, padding: bool) -> Self {
// Safety: swizzles are safe for masks
unsafe { Self::from_int_unchecked(self.to_int().shift_elements_left::<OFFSET>(padding)) }
unsafe {
Self::from_int_unchecked(self.to_int().shift_elements_left::<OFFSET>(if padding {
T::TRUE
} else {
T::FALSE
}))
}
}

/// Shifts the mask elements to the right by `OFFSET`, filling in with
/// `padding` from the left.
#[inline]
#[must_use = "method returns a new mask and does not mutate the original inputs"]
pub fn shift_elements_right<const OFFSET: usize>(self, padding: T) -> Self {
pub fn shift_elements_right<const OFFSET: usize>(self, padding: bool) -> Self {
// Safety: swizzles are safe for masks
unsafe { Self::from_int_unchecked(self.to_int().shift_elements_right::<OFFSET>(padding)) }
unsafe {
Self::from_int_unchecked(self.to_int().shift_elements_right::<OFFSET>(if padding {
T::TRUE
} else {
T::FALSE
}))
}
}

/// Interleave two masks.
Expand Down

0 comments on commit 9392fb1

Please sign in to comment.