]> git.lizzy.rs Git - rust.git/commitdiff
librand: use unboxed closures in `distributions` module
authorJorge Aparicio <japaricious@gmail.com>
Sat, 6 Dec 2014 17:30:35 +0000 (12:30 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Sat, 13 Dec 2014 22:03:46 +0000 (17:03 -0500)
src/librand/distributions/mod.rs
src/librand/lib.rs

index 0fa989bf0b2b9b4e8713bc1cc2581e5fba7a31bd..a44197c98590c74e720e45b71a19e3c9b13ebeb2 100644 (file)
@@ -208,14 +208,14 @@ fn ind_sample<R: Rng>(&self, rng: &mut R) -> T {
 // the perf improvement (25-50%) is definitely worth the extra code
 // size from force-inlining.
 #[inline(always)]
-fn ziggurat<R:Rng>(
+fn ziggurat<R: Rng, P, Z>(
             rng: &mut R,
             symmetric: bool,
             x_tab: ziggurat_tables::ZigTable,
             f_tab: ziggurat_tables::ZigTable,
-            pdf: |f64|: 'static -> f64,
-            zero_case: |&mut R, f64|: 'static -> f64)
-            -> f64 {
+            mut pdf: P,
+            mut zero_case: Z)
+            -> f64 where P: FnMut(f64) -> f64, Z: FnMut(&mut R, f64) -> f64 {
     static SCALE: f64 = (1u64 << 53) as f64;
     loop {
         // reimplement the f64 generation as an optimisation suggested
index d357f247f1b74eb68a66329e68282ab5234bb06d..4fba3707703a5f6d7ed68e3639431d61acaec32f 100644 (file)
@@ -24,6 +24,7 @@
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![feature(macro_rules, phase, globs)]
+#![feature(unboxed_closures)]
 #![no_std]
 #![experimental]