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.
| 7 | /// every element and applying the given predicate to each item, then selecting the first matching |
| 8 | /// entry. |
| 9 | pub 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 | |
| 21 | impl<T> CtFind<T> for [T] |
| 22 | where |
nothing calls this directly
no outgoing calls
no test coverage detected