pub trait SimdUint: Copy + Sealed {
type Scalar;
type Cast<T: SimdElement>;
Show 20 methods
// Required methods
fn cast<T: SimdCast>(self) -> Self::Cast<T>;
fn wrapping_neg(self) -> Self;
fn saturating_add(self, second: Self) -> Self;
fn saturating_sub(self, second: Self) -> Self;
fn abs_diff(self, second: Self) -> Self;
fn reduce_sum(self) -> Self::Scalar;
fn reduce_product(self) -> Self::Scalar;
fn reduce_max(self) -> Self::Scalar;
fn reduce_min(self) -> Self::Scalar;
fn reduce_and(self) -> Self::Scalar;
fn reduce_or(self) -> Self::Scalar;
fn reduce_xor(self) -> Self::Scalar;
fn swap_bytes(self) -> Self;
fn reverse_bits(self) -> Self;
fn count_ones(self) -> Self;
fn count_zeros(self) -> Self;
fn leading_zeros(self) -> Self;
fn trailing_zeros(self) -> Self;
fn leading_ones(self) -> Self;
fn trailing_ones(self) -> Self;
}π¬This is a nightly-only experimental API. (portable_simd #86656)
Expand description
Operations on SIMD vectors of unsigned integers.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Performs elementwise conversion of this vectorβs elements to another SIMD-valid type.
This follows the semantics of Rustβs as conversion for casting integers (wrapping to
other integer types, and saturating to float types).
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Wrapping negation.
Like u32::wrapping_neg, all applications of this function will wrap, with the exception
of -0.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Lanewise saturating add.
Β§Examples
use core::u32::MAX;
let x = Simd::from_array([2, 1, 0, MAX]);
let max = Simd::splat(MAX);
let unsat = x + max;
let sat = x.saturating_add(max);
assert_eq!(unsat, Simd::from_array([1, 0, MAX, MAX - 1]));
assert_eq!(sat, max);Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Lanewise saturating subtract.
Β§Examples
use core::u32::MAX;
let x = Simd::from_array([2, 1, 0, MAX]);
let max = Simd::splat(MAX);
let unsat = x - max;
let sat = x.saturating_sub(max);
assert_eq!(unsat, Simd::from_array([3, 2, 1, 0]));
assert_eq!(sat, Simd::splat(0));Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Lanewise absolute difference.
Every element becomes the absolute difference of self and second.
Β§Examples
use core::u32::MAX;
let a = Simd::from_array([0, MAX, 100, 20]);
let b = Simd::from_array([MAX, 0, 80, 200]);
assert_eq!(a.abs_diff(b), Simd::from_array([MAX, MAX, 20, 180]));Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the sum of the elements of the vector, with wrapping addition.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the product of the elements of the vector, with wrapping multiplication.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the maximum element in the vector.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the minimum element in the vector.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the cumulative bitwise βandβ across the elements of the vector.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the cumulative bitwise βorβ across the elements of the vector.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the cumulative bitwise βxorβ across the elements of the vector.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Reverses the byte order of each element.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Reverses the order of bits in each elemnent. The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the number of ones in the binary representation of each element.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the number of zeros in the binary representation of each element.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the number of leading zeros in the binary representation of each element.
Source π¬This is a nightly-only experimental API. (portable_simd #86656)
portable_simd #86656)Returns the number of trailing zeros in the binary representation of each element.
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.