File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,11 @@ use core::option::Option;
115
115
pub struct Choice ( u8 ) ;
116
116
117
117
impl Choice {
118
+ #[ inline]
119
+ pub ( crate ) const fn of_bool ( of : bool ) -> Self {
120
+ Self ( of as u8 )
121
+ }
122
+
118
123
/// Unwrap the `Choice` wrapper to reveal the underlying `u8`.
119
124
///
120
125
/// # Note
@@ -326,7 +331,7 @@ pub struct IteratedEq {
326
331
impl IteratedOperation for IteratedEq {
327
332
fn initiate ( ) -> Self {
328
333
Self {
329
- still_equal : Choice :: from ( 1 ) ,
334
+ still_equal : Choice :: of_bool ( true ) ,
330
335
}
331
336
}
332
337
fn extract_result ( self ) -> Choice {
@@ -335,7 +340,10 @@ impl IteratedOperation for IteratedEq {
335
340
}
336
341
337
342
impl IteratedEq {
338
- /// Unconditionally AND internal state with the result of an "equals" comparison.
343
+ /// Unconditionally AND internal state with the result of a constant-time "equals" comparison.
344
+ ///
345
+ /// [`Self::initiate()`] begins with internal state set to "true", so we can think of this
346
+ /// strategy as "assuming equal until proven wrong".
339
347
#[ inline]
340
348
pub fn apply_eq < T : ConstantTimeEq + ?Sized > ( & mut self , a : & T , b : & T ) {
341
349
self . still_equal &= a. ct_eq ( b) ;
You can’t perform that action at this time.
0 commit comments