summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2014-01-12 21:02:59 +0100
committerFlavio Percoco <flaper87@gmail.com>2014-01-17 15:41:26 +0100
commited7e576d9cf807169b17b5a4c572e874e38681cf (patch)
tree02b3ccb929e3e47154f754f3a79508fba04bface /src/libstd/sync
parent5fdc81262a5d44f10e335384b5d69b938d6d729c (diff)
downloadrust-ed7e576d9cf807169b17b5a4c572e874e38681cf.tar.gz
rust-ed7e576d9cf807169b17b5a4c572e874e38681cf.zip
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
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/mpmc_bounded_queue.rs4
1 files changed, 2 insertions, 2 deletions
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<T> {
@@ -64,7 +64,7 @@ impl<T: Send> State<T> {
                 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