pub struct Mask<const N: usize, T, A: Alignment>(/* private fields */)
where
Length<N>: SupportedLength,
T: Scalar;Expand description
A generic vector mask.
Mask is the generic form of:
Mask is generic over:
To initialize masks, use the functions Mask2::new,
Mask3::new, Mask4::new. To
initialize a mask of an unknown length, use Mask::from_array.
§Guarantees
Mask<N, T, A> doesn’t have a stable representation, but does guarantee
certain properties.
Mask<N, T, A> bytes are initialized and zeroable.
Masks of scalar types with the same Scalar::Repr are guaranteed to have
compatible memory layouts, even if Repr = (). They are guaranteed to have
the same size, element positions, and alignment.
Types containing compatible Mask types are not guaranteed to have the
same memory layout. For example, even though Mask2<bool> and Mask2<u8>
have the same memory layout, Option<Mask2<bool>> and Option<Mask2<u8>>
may not.
Implementations§
Source§impl<const N: usize, T, A: Alignment> Mask<N, T, A>
impl<const N: usize, T, A: Alignment> Mask<N, T, A>
Sourcepub fn from_array(array: [bool; N]) -> Self
pub fn from_array(array: [bool; N]) -> Self
Creates a mask from an array.
The preferable way to create masks is using the functions
Mask2::new, Mask3::new,
Mask4::new.
Mask::from_array should only be used when the length of the mask is
unknown or when directly converting from an array.
Sourcepub fn from_fn<F>(f: F) -> Self
pub fn from_fn<F>(f: F) -> Self
Creates a mask by calling function f for each component index.
Equivalent to (f(0), f(1), f(2), ...).
Sourcepub fn to_alignment<A2: Alignment>(self) -> Mask<N, T, A2>
pub fn to_alignment<A2: Alignment>(self) -> Mask<N, T, A2>
Converts the mask to the specified alignment.
See Alignment for more information.
Sourcepub fn select(
self,
if_true: Vector<N, T, A>,
if_false: Vector<N, T, A>,
) -> Vector<N, T, A>
pub fn select( self, if_true: Vector<N, T, A>, if_false: Vector<N, T, A>, ) -> Vector<N, T, A>
Selects between the components of if_true and if_false based on the
values of the mask.
Sourcepub const fn to_repr<T2>(self) -> Mask<N, T2, A>
pub const fn to_repr<T2>(self) -> Mask<N, T2, A>
Reinterprets the bits of the mask to a different scalar type.
The two scalar types must have compatible memory layouts. This is enforced via trait bounds in this function’s signature.
This function is used to make SIMD optimizations in implementations of
Scalar.
Trait Implementations§
Source§impl<const N: usize, T, A: Alignment> BitAndAssign<bool> for Mask<N, T, A>
impl<const N: usize, T, A: Alignment> BitAndAssign<bool> for Mask<N, T, A>
Source§fn bitand_assign(&mut self, rhs: bool)
fn bitand_assign(&mut self, rhs: bool)
&= operation. Read moreSource§impl<const N: usize, T, A: Alignment> BitAndAssign for Mask<N, T, A>
impl<const N: usize, T, A: Alignment> BitAndAssign for Mask<N, T, A>
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl<const N: usize, T, A: Alignment> BitOrAssign<bool> for Mask<N, T, A>
impl<const N: usize, T, A: Alignment> BitOrAssign<bool> for Mask<N, T, A>
Source§fn bitor_assign(&mut self, rhs: bool)
fn bitor_assign(&mut self, rhs: bool)
|= operation. Read moreSource§impl<const N: usize, T, A: Alignment> BitOrAssign for Mask<N, T, A>
impl<const N: usize, T, A: Alignment> BitOrAssign for Mask<N, T, A>
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl<const N: usize, T, A: Alignment> BitXorAssign<bool> for Mask<N, T, A>
impl<const N: usize, T, A: Alignment> BitXorAssign<bool> for Mask<N, T, A>
Source§fn bitxor_assign(&mut self, rhs: bool)
fn bitxor_assign(&mut self, rhs: bool)
^= operation. Read moreSource§impl<const N: usize, T, A: Alignment> BitXorAssign for Mask<N, T, A>
impl<const N: usize, T, A: Alignment> BitXorAssign for Mask<N, T, A>
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read more