MCPcopy Create free account
hub / github.com/RustCrypto/utils / CtFind

Interface CtFind

ctutils/src/traits/ct_find.rs:9–19  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

7/// every element and applying the given predicate to each item, then selecting the first matching
8/// entry.
9pub trait CtFind<T: CtAssign> {
10 /// Iterate through every `T` item in `&self`, applying the given `predicate` which can select
11 /// a specific item by returning [`Choice::TRUE`].
12 ///
13 /// The first item where `predicate` returns [`Choice::TRUE`] is selected, or the [`CtOption`]
14 /// equivalent of `None` is returned if the `predicate` returns [`Choice::FALSE`] for all items.
15 #[must_use]
16 fn ct_find<P>(&self, predicate: P) -> CtOption<T>
17 where
18 P: Fn(&T) -> Choice;
19}
20
21impl<T> CtFind<T> for [T]
22where

Callers

nothing calls this directly

Implementers 1

ct_find.rsctutils/src/traits/ct_find.rs

Calls

no outgoing calls

Tested by

no test coverage detected