Skip to content

Commit b98c0a3

Browse files
committed
---
yaml --- r: 144947 b: refs/heads/try2 c: 4946e0e h: refs/heads/master i: 144945: 3bf3b42 144943: b268c4a v: v3
1 parent 4625d1c commit b98c0a3

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 54368afc03054937e7f5a3b7a9b8cf9c8e85d962
8+
refs/heads/try2: 4946e0ea5ee727893a74321be2fb3b291f320809
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/num/bigint.rs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -521,27 +521,6 @@ impl FromStrRadix for BigUint {
521521
}
522522
}
523523

524-
trait RandBigUInt {
525-
/// Generate a random BigUint of the given bit size.
526-
fn gen_biguint(&mut self, bit_size: uint) -> BigUint;
527-
}
528-
529-
impl<R: Rng> RandBigUInt for R {
530-
/// Generate a random BigUint of the given bit size.
531-
fn gen_biguint(&mut self, bit_size: uint) -> BigUint {
532-
let (digits, rem) = bit_size.div_rem(&BigDigit::bits);
533-
let mut data = vec::with_capacity(digits+1);
534-
for _ in range(0, digits) {
535-
data.push(self.gen());
536-
}
537-
if rem > 0 {
538-
let final_digit: BigDigit = self.gen();
539-
data.push(final_digit >> (BigDigit::bits - rem));
540-
}
541-
return BigUint::new(data);
542-
}
543-
}
544-
545524
impl BigUint {
546525
/// Creates and initializes an BigUint.
547526
#[inline]
@@ -1074,12 +1053,29 @@ impl FromStrRadix for BigInt {
10741053
}
10751054
10761055
trait RandBigInt {
1056+
/// Generate a random BigUint of the given bit size.
1057+
fn gen_biguint(&mut self, bit_size: uint) -> BigUint;
1058+
10771059
/// Generate a random BigInt of the given bit size.
10781060
fn gen_bigint(&mut self, bit_size: uint) -> BigInt;
10791061
}
10801062
10811063
impl<R: Rng> RandBigInt for R {
10821064
/// Generate a random BigUint of the given bit size.
1065+
fn gen_biguint(&mut self, bit_size: uint) -> BigUint {
1066+
let (digits, rem) = bit_size.div_rem(&BigDigit::bits);
1067+
let mut data = vec::with_capacity(digits+1);
1068+
for _ in range(0, digits) {
1069+
data.push(self.gen());
1070+
}
1071+
if rem > 0 {
1072+
let final_digit: BigDigit = self.gen();
1073+
data.push(final_digit >> (BigDigit::bits - rem));
1074+
}
1075+
return BigUint::new(data);
1076+
}
1077+
1078+
/// Generate a random BigInt of the given bit size.
10831079
fn gen_bigint(&mut self, bit_size: uint) -> BigInt {
10841080
// Generate a random BigUint...
10851081
let biguint = self.gen_biguint(bit_size);

0 commit comments

Comments
 (0)