librand: use unboxed closures in distributions module

This commit is contained in:
Jorge Aparicio 2014-12-06 12:30:35 -05:00
parent 5d7543b6ba
commit 533a47bd9b
2 changed files with 5 additions and 4 deletions

View file

@ -208,14 +208,14 @@ mod ziggurat_tables;
// 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

View file

@ -24,6 +24,7 @@
html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, phase, globs)]
#![feature(unboxed_closures)]
#![no_std]
#![experimental]