From cca032e91bd02438619dffbdf5471e475787d5af Mon Sep 17 00:00:00 2001 From: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com> Date: Fri, 1 Jul 2022 05:58:12 -0400 Subject: [PATCH] expose `index_mutually_exclusive_logical_results()` --- src/lib.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 74c409a..9dd6334 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -822,7 +822,20 @@ pub trait ConstantTimePartialOrd { /// /// This method requires a whole set of logical checks to be performed before evaluating their /// result, and uses a lookup table to avoid branching in a `match` expression. -fn index_mutually_exclusive_logical_results( +/// +///``` +/// use subtle_ng::{Choice, index_mutually_exclusive_logical_results}; +/// +/// let r = [0xA, 0xB, 0xC]; +/// +/// let a = index_mutually_exclusive_logical_results(&r, [Choice::from(0), Choice::from(0)]); +/// assert_eq!(*a, 0xA); +/// let b = index_mutually_exclusive_logical_results(&r, [Choice::from(1), Choice::from(0)]); +/// assert_eq!(*b, 0xB); +/// let c = index_mutually_exclusive_logical_results(&r, [Choice::from(0), Choice::from(1)]); +/// assert_eq!(*c, 0xC); +///``` +pub fn index_mutually_exclusive_logical_results( results: &[T], logicals: [Choice; N], ) -> &T {