use crate::simd::intrinsics; use crate::simd::{LaneCount, Simd, SimdElement, SupportedLaneCount}; use core::ops::{Neg, Not}; // unary ops macro_rules! neg { ($(impl Neg for Simd<$scalar:ty, LANES>)*) => { $(impl Neg for Simd<$scalar, LANES> where $scalar: SimdElement, LaneCount: SupportedLaneCount, { type Output = Self; #[inline] #[must_use = "operator returns a new vector without mutating the input"] fn neg(self) -> Self::Output { // Safety: `self` is a signed vector unsafe { intrinsics::simd_neg(self) } } })* } } neg! { impl Neg for Simd impl Neg for Simd impl Neg for Simd impl Neg for Simd impl Neg for Simd impl Neg for Simd impl Neg for Simd } macro_rules! not { ($(impl Not for Simd<$scalar:ty, LANES>)*) => { $(impl Not for Simd<$scalar, LANES> where $scalar: SimdElement, LaneCount: SupportedLaneCount, { type Output = Self; #[inline] #[must_use = "operator returns a new vector without mutating the input"] fn not(self) -> Self::Output { self ^ (Simd::splat(!(0 as $scalar))) } })* } } not! { impl Not for Simd impl Not for Simd impl Not for Simd impl Not for Simd impl Not for Simd impl Not for Simd impl Not for Simd impl Not for Simd impl Not for Simd impl Not for Simd }