diff --git a/examples/bubble_sort_hooks.zig b/examples/bubble_sort_hooks.zig index c21a2c7..721026f 100644 --- a/examples/bubble_sort_hooks.zig +++ b/examples/bubble_sort_hooks.zig @@ -78,7 +78,7 @@ const BenchmarkData = struct { prng: std.Random.DefaultPrng, pub fn init(self: *BenchmarkData, allocator: std.mem.Allocator, num: usize) !void { - self.prng = std.rand.DefaultPrng.init(blk: { + self.prng = std.Random.DefaultPrng.init(blk: { var seed: u64 = undefined; std.posix.getrandom(std.mem.asBytes(&seed)) catch unreachable; break :blk seed; diff --git a/util/optional.zig b/util/optional.zig index 51faa60..d464ffb 100644 --- a/util/optional.zig +++ b/util/optional.zig @@ -3,9 +3,10 @@ const std = @import("std"); /// Make every field of the struct T nullable. pub fn Optional(comptime T: type) type { const T_info = switch (@typeInfo(T)) { - .Struct => |x| x, + .@"struct" => |x| x, else => @compileError("Optional only supports struct types for now"), }; + var fields: [T_info.fields.len]std.builtin.Type.StructField = undefined; for (T_info.fields, &fields) |fi, *fo| { fo.* = fi; @@ -14,14 +15,14 @@ pub fn Optional(comptime T: type) type { } var result = T_info; result.fields = &fields; - return @Type(.{ .Struct = result }); + return @Type(.{ .@"struct" = result }); } /// Take any non-null fields from x, and any null fields are taken from y /// instead. pub fn optional(comptime T: type, x: Optional(T), y: T) T { const T_info = switch (@typeInfo(T)) { - .Struct => |info| info, + .@"struct" => |info| info, else => @compileError("Optional only supports struct types for now"), }; var t: T = undefined; diff --git a/zbench.zig b/zbench.zig index 48f40c0..4f48098 100644 --- a/zbench.zig +++ b/zbench.zig @@ -149,7 +149,7 @@ pub const Benchmark = struct { ) !void { // Check the benchmark parameter is the proper type. const T: type = switch (@typeInfo(@TypeOf(benchmark))) { - .Pointer => |ptr| if (ptr.is_const) ptr.child else @compileError( + .pointer => |ptr| if (ptr.is_const) ptr.child else @compileError( "benchmark must be a const ptr to a struct with a 'run' method", ), else => @compileError(