From ed7e576d9cf807169b17b5a4c572e874e38681cf Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Sun, 12 Jan 2014 21:02:59 +0100 Subject: Add a generic power function The patch adds a `pow` function for types implementing `One`, `Mul` and `Clone` trait. The patch also renames f32 and f64 pow into powf in order to still have a way to easily have float powers. It uses llvms intrinsics. The pow implementation for all num types uses the exponentiation by square. Fixes bug #11499 --- src/libstd/sync/mpmc_bounded_queue.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd/sync') diff --git a/src/libstd/sync/mpmc_bounded_queue.rs b/src/libstd/sync/mpmc_bounded_queue.rs index 18d17eed885..bf02bf204a5 100644 --- a/src/libstd/sync/mpmc_bounded_queue.rs +++ b/src/libstd/sync/mpmc_bounded_queue.rs @@ -31,10 +31,10 @@ use clone::Clone; use kinds::Send; -use num::{Real, Round}; use option::{Option, Some, None}; use sync::arc::UnsafeArc; use sync::atomics::{AtomicUint,Relaxed,Release,Acquire}; +use uint; use vec; struct Node { @@ -64,7 +64,7 @@ impl State { 2u } else { // use next power of 2 as capacity - 2f64.pow(&((capacity as f64).log2().ceil())) as uint + uint::next_power_of_two(capacity) } } else { capacity -- cgit 1.4.1-3-g733a5