mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-02-10 22:24:52 +00:00
Merge pull request 'fix: use new randomness api' (#354) from itsnoctural/exercises:main into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/354
This commit is contained in:
commit
6972af2178
|
|
@ -87,6 +87,7 @@ that if you update one, you may need to also update the other.
|
|||
|
||||
### Version Changes
|
||||
|
||||
* 2026-01-09 zig 0.16.0-dev.2075 - move randomness API to `std.Io`, see [#30709](https://codeberg.org/ziglang/zig/pulls/30709)
|
||||
* 2026-01-07 zig 0.16.0-dev.2040 - adjust temp files, see [#30683](https://codeberg.org/ziglang/zig/pulls/30683)
|
||||
* 2026-01-06 zig 0.16.0-dev.1976 - move process API to `std.Io` and changes to main/environ/argv, see [#30644](https://codeberg.org/ziglang/zig/pulls/30644)
|
||||
* *2025-12-28* zig 0.16.0-dev.1859 - file system I/O integrated with the std.Io interface, see [#30232](https://codeberg.org/ziglang/zig/pulls/30232)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const print = std.debug.print;
|
|||
// 1) Getting Started
|
||||
// 2) Version Changes
|
||||
comptime {
|
||||
const required_zig = "0.16.0-dev.2040";
|
||||
const required_zig = "0.16.0-dev.2075";
|
||||
const current_zig = builtin.zig_version;
|
||||
const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable;
|
||||
if (current_zig.order(min_zig) == .lt) {
|
||||
|
|
@ -206,7 +206,7 @@ pub fn build(b: *Build) !void {
|
|||
|
||||
var prng = std.Random.DefaultPrng.init(blk: {
|
||||
var seed: u64 = undefined;
|
||||
try std.posix.getrandom(std.mem.asBytes(&seed));
|
||||
io.random(std.mem.asBytes(&seed));
|
||||
break :blk seed;
|
||||
});
|
||||
const rnd = prng.random();
|
||||
|
|
@ -1287,7 +1287,7 @@ const exercises = [_]Exercise{
|
|||
\\Max difference (new fn): 0.014
|
||||
,
|
||||
},
|
||||
.{ .main_file = "110_quiz9.zig", .output =
|
||||
.{ .main_file = "110_quiz9.zig", .output =
|
||||
\\Toggle pins with XOR on PORTB
|
||||
\\-----------------------------
|
||||
\\ 1100 // (initial state of PORTB)
|
||||
|
|
|
|||
|
|
@ -394,7 +394,11 @@ fn heal(allocator: Allocator, exercises: []const Exercise, work_path: []const u8
|
|||
|
||||
fn createTempPath(b: *Build) ![]const u8 {
|
||||
const io = b.graph.io;
|
||||
const rand_int = std.crypto.random.int(u64);
|
||||
const rand_int = r: {
|
||||
var x: u64 = undefined;
|
||||
io.random(@ptrCast(&x));
|
||||
break :r x;
|
||||
};
|
||||
const tmp_dir_sub_path = "tmp" ++ std.Io.Dir.path.sep_str ++ std.fmt.hex(rand_int);
|
||||
const result_path = b.cache_root.join(b.allocator, &.{tmp_dir_sub_path}) catch @panic("OOM");
|
||||
try b.cache_root.handle.createDirPath(io, tmp_dir_sub_path);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user