File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 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;
115115pub struct Choice ( u8 ) ;
116116
117117impl Choice {
118+ #[ inline]
119+ pub ( crate ) const fn of_bool ( of : bool ) -> Self {
120+ Self ( of as u8 )
121+ }
122+
118123 /// Unwrap the `Choice` wrapper to reveal the underlying `u8`.
119124 ///
120125 /// # Note
@@ -326,7 +331,7 @@ pub struct IteratedEq {
326331impl IteratedOperation for IteratedEq {
327332 fn initiate ( ) -> Self {
328333 Self {
329- still_equal : Choice :: from ( 1 ) ,
334+ still_equal : Choice :: of_bool ( true ) ,
330335 }
331336 }
332337 fn extract_result ( self ) -> Choice {
@@ -335,7 +340,10 @@ impl IteratedOperation for IteratedEq {
335340}
336341
337342impl 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".
339347 #[ inline]
340348 pub fn apply_eq < T : ConstantTimeEq + ?Sized > ( & mut self , a : & T , b : & T ) {
341349 self . still_equal &= a. ct_eq ( b) ;
You can’t perform that action at this time.
0 commit comments