From 3784d8343991f56a10b6e58f806364be5feabb84 Mon Sep 17 00:00:00 2001 From: Jakub Bogucki Date: Wed, 30 Mar 2022 11:38:01 +0200 Subject: [PATCH] uint: Make is_zero implementation const --- uint/src/uint.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/uint/src/uint.rs b/uint/src/uint.rs index 647a803d7..c136297e8 100644 --- a/uint/src/uint.rs +++ b/uint/src/uint.rs @@ -673,9 +673,10 @@ macro_rules! construct_uint { /// Whether this is zero. #[inline] - pub fn is_zero(&self) -> bool { + pub const fn is_zero(&self) -> bool { let &$name(ref arr) = self; - for i in 0..$n_words { if arr[i] != 0 { return false; } } + let mut i = 0; + while i < $n_words { if arr[i] != 0 { return false; } else { i += 1; } } return true; }