Skip to main content

cmov/
array.rs

1//! Trait impls for core arrays.
2//!
3//! Implemented generically, delegating to the slice impls.
4
5use crate::{Cmov, CmovEq, Condition};
6
7// Optimized implementation for arrays which coalesces them into word-sized chunks first,
8// then performs [`Cmov`] at the word-level to cut down on the total number of instructions.
9impl<T, const N: usize> Cmov for [T; N]
10where
11    [T]: Cmov,
12{
13    #[inline]
14    fn cmovnz(&mut self, value: &Self, condition: Condition) {
15        self.as_mut_slice().cmovnz(value, condition);
16    }
17}
18
19// Optimized implementation for arrays which coalesces them into word-sized chunks first,
20// then performs [`CmovEq`] at the word-level to cut down on the total number of instructions.
21impl<T, const N: usize> CmovEq for [T; N]
22where
23    [T]: CmovEq,
24{
25    #[inline]
26    fn cmovne(&self, rhs: &Self, input: Condition, output: &mut Condition) {
27        self.as_slice().cmovne(rhs, input, output);
28    }
29}