Skip to content

Commit 7562ab2

Browse files
bors[bot]cuviper
andauthored
Merge #155
155: Minor cleanups r=cuviper a=cuviper Co-authored-by: Josh Stone <cuviper@gmail.com>
2 parents de77bef + 7b2f725 commit 7562ab2

File tree

3 files changed

+4
-23
lines changed

3 files changed

+4
-23
lines changed

src/bigint.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ use core::str::{self, FromStr};
2020
use core::{i128, u128};
2121
use core::{i64, u64};
2222

23-
#[cfg(feature = "serde")]
24-
use serde;
25-
2623
use num_integer::{Integer, Roots};
2724
use num_traits::{
2825
CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, FromPrimitive, Num, One, Pow, PrimInt, Signed,
@@ -158,18 +155,6 @@ impl Arbitrary for BigInt {
158155
}
159156
}
160157

161-
/// Return the magnitude of a `BigInt`.
162-
#[cfg(feature = "rand")]
163-
pub(crate) fn magnitude(i: &BigInt) -> &BigUint {
164-
&i.data
165-
}
166-
167-
/// Return the owned magnitude of a `BigInt`.
168-
#[cfg(feature = "rand")]
169-
pub(crate) fn into_magnitude(i: BigInt) -> BigUint {
170-
i.data
171-
}
172-
173158
impl hash::Hash for BigInt {
174159
#[inline]
175160
fn hash<H: hash::Hasher>(&self, state: &mut H) {

src/bigrand.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::BigInt;
77
use crate::BigUint;
88
use crate::Sign::*;
99

10-
use crate::bigint::{into_magnitude, magnitude};
1110
use crate::biguint::biguint_from_vec;
1211

1312
use num_integer::Integer;
@@ -132,12 +131,12 @@ impl<R: Rng + ?Sized> RandBigInt for R {
132131
fn gen_bigint_range(&mut self, lbound: &BigInt, ubound: &BigInt) -> BigInt {
133132
assert!(*lbound < *ubound);
134133
if lbound.is_zero() {
135-
BigInt::from(self.gen_biguint_below(magnitude(&ubound)))
134+
BigInt::from(self.gen_biguint_below(ubound.magnitude()))
136135
} else if ubound.is_zero() {
137-
lbound + BigInt::from(self.gen_biguint_below(magnitude(&lbound)))
136+
lbound + BigInt::from(self.gen_biguint_below(lbound.magnitude()))
138137
} else {
139138
let delta = ubound - lbound;
140-
lbound + BigInt::from(self.gen_biguint_below(magnitude(&delta)))
139+
lbound + BigInt::from(self.gen_biguint_below(delta.magnitude()))
141140
}
142141
}
143142
}
@@ -218,7 +217,7 @@ impl UniformSampler for UniformBigInt {
218217
let high = high_b.borrow();
219218
assert!(low < high);
220219
UniformBigInt {
221-
len: into_magnitude(high - low),
220+
len: (high - low).into_parts().1,
222221
base: low.clone(),
223222
}
224223
}

src/biguint.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ use core::str::{self, FromStr};
1818
use core::{f32, f64};
1919
use core::{u32, u64, u8};
2020

21-
#[cfg(feature = "serde")]
22-
use serde;
23-
2421
use num_integer::{Integer, Roots};
2522
use num_traits::float::FloatCore;
2623
use num_traits::{

0 commit comments

Comments
 (0)