diff --git a/Cargo.toml b/Cargo.toml index 413212bd..fe15f05e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ version = "0.1.39" default-features = false [dependencies.num-traits] -version = "0.2.4" +version = "0.2.7" default-features = false [dependencies.rand] diff --git a/src/bigint.rs b/src/bigint.rs index 4df63de6..3cfc5cfd 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -756,6 +756,12 @@ impl Zero for BigInt { BigInt::from_biguint(NoSign, Zero::zero()) } + #[inline] + fn set_zero(&mut self) { + self.data.set_zero(); + self.sign = NoSign; + } + #[inline] fn is_zero(&self) -> bool { self.sign == NoSign @@ -768,6 +774,12 @@ impl One for BigInt { BigInt::from_biguint(Plus, One::one()) } + #[inline] + fn set_one(&mut self) { + self.data.set_one(); + self.sign = Plus; + } + #[inline] fn is_one(&self) -> bool { self.sign == Plus && self.data.is_one() diff --git a/src/biguint.rs b/src/biguint.rs index da953dac..f1306fef 100644 --- a/src/biguint.rs +++ b/src/biguint.rs @@ -417,6 +417,11 @@ impl Zero for BigUint { BigUint::new(Vec::new()) } + #[inline] + fn set_zero(&mut self) { + self.data.clear(); + } + #[inline] fn is_zero(&self) -> bool { self.data.is_empty() @@ -429,6 +434,12 @@ impl One for BigUint { BigUint::new(vec![1]) } + #[inline] + fn set_one(&mut self) { + self.data.clear(); + self.data.push(1); + } + #[inline] fn is_one(&self) -> bool { self.data[..] == [1]