Implementing this trait enables use of the [`CtSelect`] trait to construct `[T; N]` where `T` is the `Self` type implementing the trait, via a blanket impl. All types which impl [`Clone`] + [`CtAssignSlice`] + [`CtSelect`] will receive a blanket impl of this trait and thus also be usable with the [`CtSelect`] impl for `[T; N]`.
| 44 | /// All types which impl [`Clone`] + [`CtAssignSlice`] + [`CtSelect`] will receive a blanket impl |
| 45 | /// of this trait and thus also be usable with the [`CtSelect`] impl for `[T; N]`. |
| 46 | pub trait CtSelectArray<const N: usize>: CtSelect + Sized { |
| 47 | /// Select between `a` and `b` in constant-time based on `choice`. |
| 48 | #[must_use] |
| 49 | fn ct_select_array(a: &[Self; N], b: &[Self; N], choice: Choice) -> [Self; N] { |
| 50 | core::array::from_fn(|i| Self::ct_select(&a[i], &b[i], choice)) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | impl<T, const N: usize> CtSelect for [T; N] |
| 55 | where |
nothing calls this directly
no outgoing calls
no test coverage detected