Skip to main content

CtFind

Trait CtFind 

Source
pub trait CtFind<T: CtAssign> {
    // Required method
    fn ct_find<P>(&self, predicate: P) -> CtOption<T>
       where P: Fn(&T) -> Choice;
}
Expand description

Constant-time equivalent of Iterator::find, which can search a collection by iterating over every element and applying the given predicate to each item, then selecting the first matching entry.

Required Methods§

Source

fn ct_find<P>(&self, predicate: P) -> CtOption<T>
where P: Fn(&T) -> Choice,

Iterate through every T item in &self, applying the given predicate which can select a specific item by returning Choice::TRUE.

The first item where predicate returns Choice::TRUE is selected, or the CtOption equivalent of None is returned if the predicate returns Choice::FALSE for all items.

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.

Implementations on Foreign Types§

Source§

impl<T> CtFind<T> for [T]
where T: CtAssign + Default,

Source§

fn ct_find<P>(&self, predicate: P) -> CtOption<T>
where P: Fn(&T) -> Choice,

Source§

impl<T, const N: usize> CtFind<T> for [T; N]
where T: CtAssign + Default,

Source§

fn ct_find<P>(&self, predicate: P) -> CtOption<T>
where P: Fn(&T) -> Choice,

Implementors§