about summary refs log tree commit diff
path: root/src/libstd/num
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2014-12-07 14:15:25 -0500
committerJorge Aparicio <japaricious@gmail.com>2014-12-13 17:03:47 -0500
commitcdbb3ca9b776b066e2c93acfb60da8537d2b1c9b (patch)
tree18a305205c51df4501a5e5e73c4b275242fb5a25 /src/libstd/num
parentbe53d619f874cbe8e4d87f900060561d16405d53 (diff)
downloadrust-cdbb3ca9b776b066e2c93acfb60da8537d2b1c9b.tar.gz
rust-cdbb3ca9b776b066e2c93acfb60da8537d2b1c9b.zip
libstd: use unboxed closures
Diffstat (limited to 'src/libstd/num')
-rw-r--r--src/libstd/num/strconv.rs6
-rw-r--r--src/libstd/num/u16.rs2
-rw-r--r--src/libstd/num/u32.rs2
-rw-r--r--src/libstd/num/u64.rs2
-rw-r--r--src/libstd/num/u8.rs2
-rw-r--r--src/libstd/num/uint.rs2
-rw-r--r--src/libstd/num/uint_macros.rs4
7 files changed, 18 insertions, 2 deletions
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs
index c41f55d567f..d5c27c7fbf8 100644
--- a/src/libstd/num/strconv.rs
+++ b/src/libstd/num/strconv.rs
@@ -21,6 +21,7 @@ use char::Char;
 use kinds::Copy;
 use num;
 use num::{Int, Float, FPNaN, FPInfinite, ToPrimitive};
+use ops::FnMut;
 use slice::{SlicePrelude, CloneSliceAllocPrelude};
 use str::StrPrelude;
 use string::String;
@@ -93,7 +94,10 @@ impl Copy for SignFormat {}
 /// # Panics
 ///
 /// - Panics if `radix` < 2 or `radix` > 36.
-fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f: |u8|) {
+fn int_to_str_bytes_common<T, F>(num: T, radix: uint, sign: SignFormat, mut f: F) where
+    T: Int,
+    F: FnMut(u8),
+{
     assert!(2 <= radix && radix <= 36);
 
     let _0: T = Int::zero();
diff --git a/src/libstd/num/u16.rs b/src/libstd/num/u16.rs
index a83a66c23a5..6d9b177574a 100644
--- a/src/libstd/num/u16.rs
+++ b/src/libstd/num/u16.rs
@@ -15,4 +15,6 @@
 
 pub use core::u16::{BITS, BYTES, MIN, MAX};
 
+use ops::FnOnce;
+
 uint_module!(u16)
diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs
index 7271203b23b..0d6d17fa007 100644
--- a/src/libstd/num/u32.rs
+++ b/src/libstd/num/u32.rs
@@ -15,4 +15,6 @@
 
 pub use core::u32::{BITS, BYTES, MIN, MAX};
 
+use ops::FnOnce;
+
 uint_module!(u32)
diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs
index 25de2f3b255..ebb5d2946c5 100644
--- a/src/libstd/num/u64.rs
+++ b/src/libstd/num/u64.rs
@@ -15,4 +15,6 @@
 
 pub use core::u64::{BITS, BYTES, MIN, MAX};
 
+use ops::FnOnce;
+
 uint_module!(u64)
diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs
index 22dedeecf3b..59aea214aae 100644
--- a/src/libstd/num/u8.rs
+++ b/src/libstd/num/u8.rs
@@ -15,4 +15,6 @@
 
 pub use core::u8::{BITS, BYTES, MIN, MAX};
 
+use ops::FnOnce;
+
 uint_module!(u8)
diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs
index a425aab3aa1..484d28dfed0 100644
--- a/src/libstd/num/uint.rs
+++ b/src/libstd/num/uint.rs
@@ -15,4 +15,6 @@
 
 pub use core::uint::{BITS, BYTES, MIN, MAX};
 
+use ops::FnOnce;
+
 uint_module!(uint)
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index 0baefb11cf8..bd6f3d4bb28 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -32,7 +32,9 @@ macro_rules! uint_module (($T:ty) => (
 /// ```
 #[inline]
 #[deprecated = "just use .to_string(), or a BufWriter with write! if you mustn't allocate"]
-pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
+pub fn to_str_bytes<U, F>(n: $T, radix: uint, f: F) -> U where
+    F: FnOnce(&[u8]) -> U,
+{
     use io::{Writer, Seek};
     // The radix can be as low as 2, so we need at least 64 characters for a
     // base 2 number, and then we need another for a possible '-' character.