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:
i8,i16,i32,i64,i128,isizeu8,u16,u32,u64,u128,usizeNonZeroI8,NonZeroI16,NonZeroI32,NonZeroI64,NonZeroI128NonZeroU8,NonZeroU16,NonZeroU32,NonZeroU64,NonZeroU128cmp::OrderingChoice[T; N]whereTimplsCtSelectArray, which the previously mentioned types all do, as well as any type which implsClone+CtAssignSlice+CtSelect.
Required Methods§
Sourcefn ct_select(&self, other: &Self, choice: Choice) -> Self
fn ct_select(&self, other: &Self, choice: Choice) -> Self
Select between self and other based on choice, returning a copy of the value.
§Returns
selfifchoiceisChoice::FALSE.otherifchoiceisChoice::TRUE.
Provided Methods§
Sourcefn ct_swap(&mut self, other: &mut Self, choice: Choice)
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", so this trait is not object safe.