diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-05 06:49:50 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-05 06:50:06 -0700 |
| commit | 4ce0fcb569ffa1c0807aaada4ded802816272b75 (patch) | |
| tree | c4fd6d6496d4caf9e11dc7c0ae00d321d292a68a /example/rand | |
| parent | 3327b0488d869710940bbd834a3d1e41758a61b5 (diff) | |
| download | zig-4ce0fcb569ffa1c0807aaada4ded802816272b75.tar.gz zig-4ce0fcb569ffa1c0807aaada4ded802816272b75.zip | |
fix some errors in rand example
Diffstat (limited to 'example/rand')
| -rw-r--r-- | example/rand/main.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/example/rand/main.zig b/example/rand/main.zig index 1b6d18122b..bf763aa652 100644 --- a/example/rand/main.zig +++ b/example/rand/main.zig @@ -1,5 +1,7 @@ export executable "rand"; +use "std.zig"; + // Mersenne Twister const ARRAY_SIZE : u16 = 624; @@ -27,7 +29,7 @@ struct Rand { /// Write `count` bytes of randomness into `buf`. pub fn get_bytes(r: &Rand, buf: &u8, count: usize) { - var bytes_left = r.get_bytes_aligned(buf, buf, count); + var bytes_left = r.get_bytes_aligned(buf, count); if (bytes_left > 0) { var rand_val_array : [u8; #sizeof(u32)]; *(rand_val_array.ptr as &u32) = r.get(); @@ -47,7 +49,7 @@ struct Rand { var rand_val_array : [u8; #sizeof(u64)]; while (true) { - r.get_bytes_aligned(r, rand_val_array.ptr, rand_val_array.len); + r.get_bytes_aligned(rand_val_array.ptr, rand_val_array.len); const rand_val = *(rand_val_array.ptr as &u64); if (rand_val < upper_bound) { return start + (rand_val % range); |
