From 3c5a94452a46a22990fb6e9c4b41a653d0e360ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Adri=C3=A1n=20Arroyo=20Calle?= Date: Fri, 20 Aug 2021 12:38:15 +0200 Subject: [PATCH] Fix #1009 by providing a naive num-bigint implementation of count_ones --- crates/num-rug-adapter/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/num-rug-adapter/src/lib.rs b/crates/num-rug-adapter/src/lib.rs index a95d42c8..2f67b80d 100644 --- a/crates/num-rug-adapter/src/lib.rs +++ b/crates/num-rug-adapter/src/lib.rs @@ -117,6 +117,10 @@ impl Integer { pub fn gcd(&self, other: &Self) -> Self { Integer(num_integer::Integer::gcd(&self.0, &other.0)) } + + pub fn count_ones(&self) -> Option { + Some(self.0.to_u32_digits().1.iter().map(|&d| d.count_ones()).sum()) + } } impl From<&Integer> for Integer { -- 2.54.0