pub trait SimdValue: Sized {
type Element: SimdValue<Element = Self::Element, SimdBool = bool>;
type SimdBool: SimdBool;
const LANES: usize;
// Required methods
fn splat(val: Self::Element) -> Self;
fn extract(&self, i: usize) -> Self::Element;
unsafe fn extract_unchecked(&self, i: usize) -> Self::Element;
fn replace(&mut self, i: usize, val: Self::Element);
unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element);
fn select(self, cond: Self::SimdBool, other: Self) -> Self;
// Provided methods
fn map_lanes(self, f: impl Fn(Self::Element) -> Self::Element) -> Self
where Self: Clone { ... }
fn zip_map_lanes(
self,
b: Self,
f: impl Fn(Self::Element, Self::Element) -> Self::Element,
) -> Self
where Self: Clone { ... }
}
Expand description
Base trait for every SIMD types.
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn extract(&self, i: usize) -> Self::Element
fn extract(&self, i: usize) -> Self::Element
Extracts the i-th lane of self
.
Panics if i >= Self::LANES
.
Sourceunsafe fn extract_unchecked(&self, i: usize) -> Self::Element
unsafe fn extract_unchecked(&self, i: usize) -> Self::Element
Extracts the i-th lane of self
without bound-checking.
§Safety
Undefined behavior if i >= Self::LANES
.
Sourcefn replace(&mut self, i: usize, val: Self::Element)
fn replace(&mut self, i: usize, val: Self::Element)
Replaces the i-th lane of self
by val
.
Panics if i >= Self::LANES
.
Sourceunsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element)
unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element)
Replaces the i-th lane of self
by val
without bound-checking.
§Safety
Undefined behavior if i >= Self::LANES
.
Sourcefn select(self, cond: Self::SimdBool, other: Self) -> Self
fn select(self, cond: Self::SimdBool, other: Self) -> Self
Merges self
and other
depending on the lanes of cond
.
For each lane of cond
with bits set to 1, the result’s will contain the value of the lane of self
.
For each lane of cond
with bits set to 0, the result’s will contain the value of the lane of other
.
Provided Methods§
Sourcefn map_lanes(self, f: impl Fn(Self::Element) -> Self::Element) -> Selfwhere
Self: Clone,
fn map_lanes(self, f: impl Fn(Self::Element) -> Self::Element) -> Selfwhere
Self: Clone,
Applies a function to each lane of self
.
Note that, while convenient, this method can be extremely slow as this
requires to extract each lane of self
and then combine them again into
a new SIMD value.
Sourcefn zip_map_lanes(
self,
b: Self,
f: impl Fn(Self::Element, Self::Element) -> Self::Element,
) -> Selfwhere
Self: Clone,
fn zip_map_lanes(
self,
b: Self,
f: impl Fn(Self::Element, Self::Element) -> Self::Element,
) -> Selfwhere
Self: Clone,
Applies a function to each lane of self
paired with the corresponding lane of b
.
Note that, while convenient, this method can be extremely slow as this
requires to extract each lane of self
and then combine them again into
a new SIMD value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.