Fix #1009 by providing a naive num-bigint implementation of count_ones

This commit is contained in:
Adrián Arroyo Calle
2021-08-20 12:38:15 +02:00
parent fce7f8aa68
commit 3c5a94452a

View File

@@ -117,6 +117,10 @@ impl Integer {
pub fn gcd(&self, other: &Self) -> Self { pub fn gcd(&self, other: &Self) -> Self {
Integer(num_integer::Integer::gcd(&self.0, &other.0)) Integer(num_integer::Integer::gcd(&self.0, &other.0))
} }
pub fn count_ones(&self) -> Option<u32> {
Some(self.0.to_u32_digits().1.iter().map(|&d| d.count_ones()).sum())
}
} }
impl From<&Integer> for Integer { impl From<&Integer> for Integer {