Skip to content

Commit 1f93467

Browse files
committed
Update to (b4c965ee8 2015-03-02) (built 2015-03-03)
`Int::pow()` takes u32 instead of usize; see rust-lang/rust#22087.
1 parent 1c9cd2a commit 1f93467

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/perfect_power.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ pub fn as_perfect_power(x: u64) -> (u64, u8) {
2121
return (x, 1)
2222
}
2323

24-
let floor_log_2 = 64 - x.leading_zeros() - 1;
24+
let floor_log_2 = 64 - x.leading_zeros() as u32 - 1;
2525

2626
let x_ = x as f64;
2727
let mut last = (x, 1);
2828
// TODO: we could be smarter about this: we know all the possible
2929
// primes that can divide the exponent (since we have a list up to
3030
// 251 >= 64), so we really only need to check them.
31-
let mut expn = 2;
31+
let mut expn: u32 = 2;
3232
let mut step = 1;
3333
while expn <= floor_log_2 {
3434
let factor = x_.powf(1.0/expn as f64).round() as u64;
@@ -106,7 +106,7 @@ mod tests {
106106
// include 1 to test p itself.
107107
for (q, is_prime) in Some((1, true)).into_iter().chain(subprimes) {
108108
let pq = p * q as u64;
109-
for n in range(1, MAX.log(pq as f64) as usize) {
109+
for n in range(1, MAX.log(pq as f64) as u32) {
110110
let x = pq.pow(n);
111111

112112
let expected = (pq, n as u8);

src/sieve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ mod tests {
318318

319319
// break into the two parts
320320
let (low, hi) = real.as_slice().split_at(last_short_prime);
321-
let leftover = hi.iter().fold(1, |x, &(p, i)| x * p.pow(i));
321+
let leftover = hi.iter().fold(1, |x, &(p, i)| x * p.pow(i as u32));
322322

323323
assert_eq!(possible, Err((leftover, low.to_vec())));
324324
continue 'next_n;

0 commit comments

Comments
 (0)