Skip to main content

CtSelect

Trait CtSelect 

Source
pub trait CtSelect: Sized {
    // Required method
    fn ct_select(&self, other: &Self, choice: Choice) -> Self;

    // Provided method
    fn ct_swap(&mut self, other: &mut Self, choice: Choice) { ... }
}
Expand description

Constant-time selection: choose between two values based on a given Choice.

This crate provides built-in implementations for the following types:

Required Methods§

Source

fn ct_select(&self, other: &Self, choice: Choice) -> Self

Select between self and other based on choice, returning a copy of the value.

§Returns

Provided Methods§

Source

fn ct_swap(&mut self, other: &mut Self, choice: Choice)

Conditionally swap self and other if choice is Choice::TRUE.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, const N: usize> CtSelect for [T; N]
where T: CtSelectArray<N>,

Source§

fn ct_select(&self, other: &Self, choice: Choice) -> Self

Implementors§