diff --git a/Cargo.toml b/Cargo.toml index 7206592..c70aa5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,15 +22,15 @@ name = "algebraics" crate-type = ["rlib", "cdylib"] [dependencies] -num-traits = "0.2" -num-bigint = "0.2" -num-integer = "0.1" -num-rational = "0.2" -rand = "0.5" -rand_pcg = "0.1.1" -lazy_static = "1.4" +num-traits = "0.2.14" +num-bigint = "0.4.3" +num-integer = "0.1.44" +num-rational = "0.4.0" +rand = "0.8.5" +rand_pcg = "0.3.1" +lazy_static = "1.4.0" [dependencies.pyo3] -version = "0.9.0" +version = "0.16.2" optional = true features = ["num-bigint"] diff --git a/src/traits.rs b/src/traits.rs index 82390d1..5d7d263 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -5,6 +5,7 @@ use num_bigint::{BigInt, BigUint}; use num_integer::Integer; use num_rational::Ratio; use num_traits::{CheckedDiv, CheckedMul, CheckedRem, NumAssign, One, Signed, ToPrimitive, Zero}; +use std::convert::TryInto; use std::{ fmt, ops::{Add, Div, DivAssign, Mul}, @@ -401,7 +402,7 @@ impl CeilLog2 for BigUint { if self.is_zero() { None } else { - Some((self - 1u32).bits()) + Some((self - 1u32).bits().try_into().unwrap()) } } } @@ -411,7 +412,7 @@ impl FloorLog2 for BigUint { if self.is_zero() { None } else { - Some(self.bits() - 1) + Some((self.bits() - 1).try_into().unwrap()) } } } @@ -445,7 +446,7 @@ impl TrailingZeros for BigUint { impl CeilLog2 for BigInt { fn ceil_log2(&self) -> Option { if self.is_positive() { - Some((self - 1u32).bits()) + Some((self - 1u32).bits().try_into().unwrap()) } else { None } @@ -455,7 +456,7 @@ impl CeilLog2 for BigInt { impl FloorLog2 for BigInt { fn floor_log2(&self) -> Option { if self.is_positive() { - Some(self.bits() - 1) + Some((self.bits() - 1).try_into().unwrap()) } else { None }