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

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