From e27fc674f52d900d28037095ef4dc3c80670fd75 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 22 Aug 2018 23:45:56 +0100 Subject: [PATCH] Tidy up DiversifierIndex::increment() --- src/lib.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b89576f..088a8a1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -286,19 +286,15 @@ impl DiversifierIndex { } pub fn increment(&mut self) -> Result<(), ()> { - let mut k = 0; - loop { + for k in 0..11 { self.0[k] = self.0[k].wrapping_add(1); if self.0[k] != 0 { // No overflow return Ok(()); } - // Overflow - k += 1; - if k == 11 { - return Err(()); - } } + // Overflow + Err(()) } }