Constant-time conditional negation: negates a value when `choice` is [`Choice::TRUE`]. Integer implementations use wrapping negation, including signed and non-zero integers. Negating a signed integer's minimum value therefore returns that value.
| 9 | /// Integer implementations use wrapping negation, including signed and non-zero integers. |
| 10 | /// Negating a signed integer's minimum value therefore returns that value. |
| 11 | pub trait CtNeg: Sized { |
| 12 | /// Conditionally negate `self`, returning `-self` if `choice` is [`Choice::TRUE`], or `self` |
| 13 | /// otherwise. |
| 14 | #[must_use] |
| 15 | fn ct_neg(&self, choice: Choice) -> Self; |
| 16 | |
| 17 | /// Conditionally negate `self` in-place, replacing it with `-self` if `choice` is |
| 18 | /// [`Choice::TRUE`]. |
| 19 | fn ct_neg_assign(&mut self, choice: Choice) { |
| 20 | *self = self.ct_neg(choice); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | // Impl `CtNeg` for a signed integer (`i*`) type which impls `CtSelect` |
| 25 | macro_rules! impl_signed_ct_neg { |
nothing calls this directly
no outgoing calls
no test coverage detected