Implementing this trait enables use of the [`CtAssign`] trait for `[T]` where `T` is the `Self` type implementing the trait, via a blanket impl. It needs to be a separate trait from [`CtAssign`] because we need to be able to impl [`CtAssign`] for `[T]` which is `?Sized`.
| 36 | /// It needs to be a separate trait from [`CtAssign`] because we need to be able to impl |
| 37 | /// [`CtAssign`] for `[T]` which is `?Sized`. |
| 38 | pub trait CtAssignSlice: CtAssign + Sized { |
| 39 | /// Conditionally assign `src` to `dst` if `choice` is [`Choice::TRUE`], or leave it unchanged |
| 40 | /// for [`Choice::FALSE`]. |
| 41 | fn ct_assign_slice(dst: &mut [Self], src: &[Self], choice: Choice) { |
| 42 | assert_eq!( |
| 43 | dst.len(), |
| 44 | src.len(), |
| 45 | "source slice length ({}) does not match destination slice length ({})", |
| 46 | src.len(), |
| 47 | dst.len() |
| 48 | ); |
| 49 | |
| 50 | for (a, b) in dst.iter_mut().zip(src) { |
| 51 | a.ct_assign(b, choice); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | impl<T: CtAssignSlice> CtAssign for [T] { |
| 57 | fn ct_assign(&mut self, src: &[T], choice: Choice) { |
nothing calls this directly
no outgoing calls
no test coverage detected