Trait timing_shield::TpCondSwap
[−]
[src]
pub trait TpCondSwap { fn tp_cond_swap(condition: TpBool, a: &mut Self, b: &mut Self); }
A trait for performing conditional swaps of two values without leaking whether the swap occurred.
For convenience, you may want to use the select
or
cond_swap
methods on TpBool
instead of using this trait directly:
let condition: TpBool; let mut a: TpU32; let mut b: TpU32; // ... condition.cond_swap(&mut a, &mut b); // OR: let a_if_true = condition.select(a, b);
This trait doesn't really make sense to implement on non-Tp
types.
Required Methods
fn tp_cond_swap(condition: TpBool, a: &mut Self, b: &mut Self)
Swap a
and b
if and only if condition
is true.
Implementers of this trait must take care to avoid leaking whether the swap occurred.
Implementors
impl<T> TpCondSwap for [T] where
T: TpCondSwap,impl<T> TpCondSwap for Vec<T> where
T: TpCondSwap,impl TpCondSwap for TpU8
impl TpCondSwap for TpU16
impl TpCondSwap for TpU32
impl TpCondSwap for TpU64
impl TpCondSwap for TpI8
impl TpCondSwap for TpI16
impl TpCondSwap for TpI32
impl TpCondSwap for TpI64
impl TpCondSwap for TpBool