blob: 96dcbaf7d73f5406e0bbd918e117a3859ef8eafa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/**
* Bindings the runtime's random number generator (ISAAC).
*/
native "rust" mod rustrt {
type rctx;
fn rand_new() -> rctx;
fn rand_next(rctx c) -> u32;
fn rand_free(rctx c);
}
type rng = obj { fn next() -> u32; };
fn mk_rng() -> rng {
obj rt_rng(rustrt.rctx c) {
fn next() -> u32 {
ret rustrt.rand_next(c);
}
drop {
rustrt.rand_free(c);
}
}
ret rt_rng(rustrt.rand_new());
}
|