diff --git a/src/AnyReader.zig b/src/AnyReader.zig index 62571a6330d347eabb6b3e198e93f43a05d36a0d..adfcde91f088fbd5f4c65212f60cf856436dd906 100644 --- a/src/AnyReader.zig +++ b/src/AnyReader.zig @@ -12,7 +12,7 @@ pub const AnyReader = struct { const ctx = reader.context; const Ctx = @TypeOf(ctx); switch (@typeInfo(Ctx)) { - .Pointer => { + .pointer => { const S = struct { fn foo(s: *anyopaque, buffer: []u8) anyerror!usize { const r = R{ .context = @ptrCast(@alignCast(s)) }; @@ -24,7 +24,7 @@ pub const AnyReader = struct { .state = ctx, }; }, - .Struct => switch (R) { + .@"struct" => switch (R) { std.fs.File.Reader => { const S = struct { fn foo(s: *anyopaque, buffer: []u8) anyerror!usize { diff --git a/src/FieldUnion.zig b/src/FieldUnion.zig index 9ccc6d18851bdc8128126c1f121fe079620921c7..95b47458f8176c1ca796063cf50733e212fa9cfd 100644 --- a/src/FieldUnion.zig +++ b/src/FieldUnion.zig @@ -14,7 +14,7 @@ pub fn FieldUnion(comptime T: type) type { .alignment = field.alignment, }; } - return @Type(std.builtin.Type{ .Union = .{ + return @Type(std.builtin.Type{ .@"union" = .{ .layout = .auto, .tag_type = std.meta.FieldEnum(T), .fields = &fields, diff --git a/src/FlippedInt.zig b/src/FlippedInt.zig index 4334b4ca6bdccb05d7eb82bd83f6202f9aae607a..b802da581cbe07d178f2715fc981fa0124485bff 100644 --- a/src/FlippedInt.zig +++ b/src/FlippedInt.zig @@ -4,7 +4,7 @@ const extras = @import("./lib.zig"); pub fn FlippedInt(comptime T: type) type { var info = @typeInfo(T); - info.Int.signedness = switch (info.Int.signedness) { + info.int.signedness = switch (info.int.signedness) { .signed => .unsigned, .unsigned => .signed, }; diff --git a/src/OneBiggerInt.zig b/src/OneBiggerInt.zig index 2da7b12b61cdd5399cf4fd2e9cd6f71d4020ccc2..556e2eb6091b99d723b0c89d1e89966bfc4ffa6d 100644 --- a/src/OneBiggerInt.zig +++ b/src/OneBiggerInt.zig @@ -4,7 +4,7 @@ const extras = @import("./lib.zig"); pub fn OneBiggerInt(comptime T: type) type { var info = @typeInfo(T); - info.Int.bits += 1; + info.int.bits += 1; return @Type(info); } diff --git a/src/OneSmallerInt.zig b/src/OneSmallerInt.zig index 2e60a0f6afc4489641d42d068b3e573707d51139..87618a5a68d02c684a26fc25c34c41c23a9755bd 100644 --- a/src/OneSmallerInt.zig +++ b/src/OneSmallerInt.zig @@ -4,7 +4,7 @@ const extras = @import("./lib.zig"); pub fn OneSmallerInt(comptime T: type) type { var info = @typeInfo(T); - info.Int.bits -= 1; + info.int.bits -= 1; return @Type(info); } diff --git a/src/Partial.zig b/src/Partial.zig index c702a7ba89bec32ad1662c6b0d6dc20223c48e30..a75060d8f0f0c4d796fa345c36213c0726412e5d 100644 --- a/src/Partial.zig +++ b/src/Partial.zig @@ -12,12 +12,12 @@ pub fn Partial(comptime T: type) type { fields_after[i] = std.builtin.Type.StructField{ .name = item.name, .type = ?item.type, - .default_value = &@as(?item.type, null), + .default_value_ptr = &@as(?item.type, null), .is_comptime = false, .alignment = @alignOf(?item.type), }; } - return @Type(@unionInit(std.builtin.Type, "Struct", .{ + return @Type(@unionInit(std.builtin.Type, "struct", .{ .layout = .auto, .backing_integer = null, .fields = &fields_after, diff --git a/src/ReverseFields.zig b/src/ReverseFields.zig index 514a0a46f8ee5b8380ada3f7efc823d5d76ebd96..5b259297021422612eb86164d92baf02550f1ba7 100644 --- a/src/ReverseFields.zig +++ b/src/ReverseFields.zig @@ -4,14 +4,14 @@ const extras = @import("./lib.zig"); const expectSimilarType = extras.expectSimilarType; pub fn ReverseFields(comptime T: type) type { - var info = @typeInfo(T).Struct; + var info = @typeInfo(T).@"struct"; const len = info.fields.len; var fields: [len]std.builtin.Type.StructField = undefined; for (0..len) |i| { fields[i] = info.fields[len - 1 - i]; } info.fields = &fields; - return @Type(.{ .Struct = info }); + return @Type(.{ .@"struct" = info }); } test { diff --git a/src/StructOfArrays.zig b/src/StructOfArrays.zig index a7720c80702cf98910ea8b31fc0715e2ae8795c5..81d818c28702b7f0939cc2a64a8a8ea24aea39a6 100644 --- a/src/StructOfArrays.zig +++ b/src/StructOfArrays.zig @@ -10,13 +10,13 @@ pub fn StructOfArrays(len: usize, T: type) type { new_fields[i] = .{ .name = item.name, .type = [len]item.type, - .default_value = null, + .default_value_ptr = null, .is_comptime = false, .alignment = @alignOf([len]item.type), }; } const result = new_fields[0..fields.len]; - return @Type(@unionInit(std.builtin.Type, "Struct", .{ + return @Type(@unionInit(std.builtin.Type, "struct", .{ .layout = .auto, .backing_integer = null, .fields = result, diff --git a/src/StructOfSlices.zig b/src/StructOfSlices.zig index 5f9be7e6a3a7cc01980f63b5f0876017fa636118..43278ab37b6c063032e11dc46a25fc0fd3c4b684 100644 --- a/src/StructOfSlices.zig +++ b/src/StructOfSlices.zig @@ -10,13 +10,13 @@ pub fn StructOfSlices(T: type) type { new_fields[i] = .{ .name = item.name, .type = []const item.type, - .default_value = null, + .default_value_ptr = null, .is_comptime = false, .alignment = @alignOf([]const item.type), }; } const result = new_fields[0..fields.len]; - return @Type(@unionInit(std.builtin.Type, "Struct", .{ + return @Type(@unionInit(std.builtin.Type, "struct", .{ .layout = .auto, .backing_integer = null, .fields = result, diff --git a/src/expectSimilarType.zig b/src/expectSimilarType.zig index dd9876e44ca06327e15b9688271fb0dff9091ac4..8eaccedf00ad9513d49280cd6ab856a492753a47 100644 --- a/src/expectSimilarType.zig +++ b/src/expectSimilarType.zig @@ -7,9 +7,9 @@ pub fn expectSimilarType(comptime A: type, comptime B: type) !void { const info_b = @typeInfo(B); try std.testing.expect(std.meta.activeTag(info_a) == std.meta.activeTag(info_b)); - if (info_a == .Struct) { - const info_a_s = info_a.Struct; - const info_b_s = info_b.Struct; + if (info_a == .@"struct") { + const info_a_s = info_a.@"struct"; + const info_b_s = info_b.@"struct"; try std.testing.expect(info_a_s.layout == info_b_s.layout); try std.testing.expect(info_a_s.is_tuple == info_b_s.is_tuple); @@ -24,9 +24,9 @@ pub fn expectSimilarType(comptime A: type, comptime B: type) !void { return; } - if (info_a == .Union) { - const info_a_u = info_a.Union; - const info_b_u = info_b.Union; + if (info_a == .@"union") { + const info_a_u = info_a.@"union"; + const info_b_u = info_b.@"union"; try std.testing.expect(info_a_u.layout == info_b_u.layout); try expectSimilarType(info_a_u.tag_type.?, info_b_u.tag_type.?); @@ -39,9 +39,9 @@ pub fn expectSimilarType(comptime A: type, comptime B: type) !void { return; } - if (info_a == .Enum) { - const info_a_e = info_a.Enum; - const info_b_e = info_b.Enum; + if (info_a == .@"enum") { + const info_a_e = info_a.@"enum"; + const info_b_e = info_b.@"enum"; try std.testing.expect(info_a_e.tag_type == info_b_e.tag_type); try std.testing.expect(info_a_e.is_exhaustive == info_b_e.is_exhaustive); diff --git a/src/hasFn.zig b/src/hasFn.zig index 1e583d1bc98ef76c09abe6e58267932b58ef5db3..a9032af9b7290ecf3c8dfeeafbfabd0a6fb07c28 100644 --- a/src/hasFn.zig +++ b/src/hasFn.zig @@ -8,7 +8,7 @@ pub fn hasFn(comptime name: []const u8) fn (type) bool { if (!comptime extras.isContainer(T)) return false; if (!comptime @hasDecl(T, name)) return false; const DeclType = @TypeOf(@field(T, name)); - return @typeInfo(DeclType) == .Fn; + return @typeInfo(DeclType) == .@"fn"; } }; return Closure.trait; diff --git a/src/isArrayOf.zig b/src/isArrayOf.zig index 2630ecb2263dd22f3a3954d9e01f5bdc6e004e27..95b896bb06a8fbb13d86bf1a484d94bdf5fb2f22 100644 --- a/src/isArrayOf.zig +++ b/src/isArrayOf.zig @@ -6,7 +6,7 @@ pub fn isArrayOf(comptime T: type) fn (type) bool { const Closure = struct { pub fn trait(comptime C: type) bool { return switch (@typeInfo(C)) { - .Array => |ti| ti.child == T, + .array => |ti| ti.child == T, else => false, }; } diff --git a/src/isContainer.zig b/src/isContainer.zig index 3adf2c33e9c275cfa0ffc659df25f3c832583471..ccb0ff343d8d839751e67d1501d050a7a2f45dbb 100644 --- a/src/isContainer.zig +++ b/src/isContainer.zig @@ -4,10 +4,10 @@ const extras = @import("./lib.zig"); pub fn isContainer(comptime T: type) bool { return switch (@typeInfo(T)) { - .Struct, - .Union, - .Enum, - .Opaque, + .@"struct", + .@"union", + .@"enum", + .@"opaque", => true, else => false, }; diff --git a/src/isIndexable.zig b/src/isIndexable.zig index ec59ec2a2d4fd3355bcd9ab524dfc84084a2cfc9..8afe9cf018685b7765c0b8d09874c8b3feb63ea6 100644 --- a/src/isIndexable.zig +++ b/src/isIndexable.zig @@ -3,13 +3,13 @@ const string = []const u8; const extras = @import("./lib.zig"); pub fn isIndexable(comptime T: type) bool { - if (comptime is(.Pointer)(T)) { - if (@typeInfo(T).Pointer.size == .One) { - return (comptime is(.Array)(std.meta.Child(T))); + if (comptime is(.pointer)(T)) { + if (@typeInfo(T).pointer.size == .one) { + return (comptime is(.array)(std.meta.Child(T))); } return true; } - return comptime is(.Array)(T) or is(.Vector)(T) or isTuple(T); + return comptime is(.array)(T) or is(.vector)(T) or isTuple(T); } fn is(comptime id: std.builtin.TypeId) fn (type) bool { const Closure = struct { @@ -20,7 +20,7 @@ fn is(comptime id: std.builtin.TypeId) fn (type) bool { return Closure.trait; } fn isTuple(comptime T: type) bool { - return is(.Struct)(T) and @typeInfo(T).Struct.is_tuple; + return is(.@"struct")(T) and @typeInfo(T).@"struct".is_tuple; } test { diff --git a/src/isSlice.zig b/src/isSlice.zig index be8cb41f61e57ad4f26ae5e31d715864bed85951..c210113fbd297d3c69e64d3a3bc8e010047901fb 100644 --- a/src/isSlice.zig +++ b/src/isSlice.zig @@ -3,9 +3,9 @@ const string = []const u8; const extras = @import("./lib.zig"); pub fn isSlice(comptime T: type) bool { - if (comptime is(.Pointer)(T)) { - if (@typeInfo(T).Pointer.size == .Slice) return true; - if (@typeInfo(T).Pointer.size == .One and is(.Array)(std.meta.Child(T))) return true; + if (comptime is(.pointer)(T)) { + if (@typeInfo(T).pointer.size == .slice) return true; + if (@typeInfo(T).pointer.size == .one and is(.array)(std.meta.Child(T))) return true; } return false; } diff --git a/src/isZigString.zig b/src/isZigString.zig index 08986ffed432465265ddbad706b09522cc36ce6e..6896007a208d1f199041cf6c584c08143995ebaa 100644 --- a/src/isZigString.zig +++ b/src/isZigString.zig @@ -18,22 +18,22 @@ pub fn isZigString(comptime T: type) bool { return comptime blk: { // Only pointer types can be strings, no optionals const info = @typeInfo(T); - if (info != .Pointer) break :blk false; + if (info != .pointer) break :blk false; - const ptr = &info.Pointer; + const ptr = &info.pointer; // Check for CV qualifiers that would prevent coerction to []const u8 if (ptr.is_volatile or ptr.is_allowzero) break :blk false; // If it's already a slice, simple check. - if (ptr.size == .Slice) { + if (ptr.size == .slice) { break :blk ptr.child == u8; } // Otherwise check if it's an array type that coerces to slice. - if (ptr.size == .One) { + if (ptr.size == .one) { const child = @typeInfo(ptr.child); - if (child == .Array) { - const arr = &child.Array; + if (child == .array) { + const arr = &child.array; break :blk arr.child == u8; } } diff --git a/src/pipe.zig b/src/pipe.zig index 50ce7a3603b7292421c5f99edacac63066ccdb95..9380b4da5a088b970732d0885ffed865c11fbe22 100644 --- a/src/pipe.zig +++ b/src/pipe.zig @@ -3,7 +3,7 @@ const string = []const u8; const extras = @import("./lib.zig"); pub fn pipe(reader_from: anytype, writer_to: anytype) !void { - var buf: [std.mem.page_size]u8 = undefined; + var buf: [std.heap.page_size_min]u8 = undefined; var fifo = std.fifo.LinearFifo(u8, .Slice).init(&buf); defer fifo.deinit(); try fifo.pump(reader_from, writer_to); diff --git a/src/randomSlice.zig b/src/randomSlice.zig index 0014d24c9983cdf76a3d4d5e7be041b8b4f63e5c..bb38de40da3dc583f83ef5b5479250d2399edd86 100644 --- a/src/randomSlice.zig +++ b/src/randomSlice.zig @@ -4,7 +4,7 @@ const extras = @import("./lib.zig"); const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; -pub fn randomSlice(alloc: std.mem.Allocator, rand: std.rand.Random, comptime T: type, len: usize) ![]T { +pub fn randomSlice(alloc: std.mem.Allocator, rand: std.Random, comptime T: type, len: usize) ![]T { var buf = try alloc.alloc(T, len); var i: usize = 0; while (i < len) : (i += 1) { diff --git a/src/rawInt.zig b/src/rawInt.zig index 8cc1dd39bf5e509702eb5ff3151f0cde810f1ca6..b3103d2fb0636a341db9697c47705476f9500337 100644 --- a/src/rawInt.zig +++ b/src/rawInt.zig @@ -5,7 +5,7 @@ const builtin = @import("builtin"); const native_endian = builtin.target.cpu.arch.endian(); pub fn rawInt(comptime T: type, comptime literal: comptime_int) T { - comptime std.debug.assert(@typeInfo(T).Int.bits % 8 == 0); + comptime std.debug.assert(@typeInfo(T).int.bits % 8 == 0); return switch (native_endian) { .little => @byteSwap(@as(T, literal)), .big => @compileError("unreachable"), diff --git a/src/readType.zig b/src/readType.zig index 25d9872babf9bbf9d8f887bfc3e3937fd8246481..e1531813c260a2f3f48598c3037a3e2c3273865e 100644 --- a/src/readType.zig +++ b/src/readType.zig @@ -8,7 +8,7 @@ const rawIntBytes = extras.rawIntBytes; pub fn readType(reader: anytype, comptime T: type, endian: std.builtin.Endian) !T { if (T == u8) return reader.readByte(); // single bytes dont have an endianness return switch (@typeInfo(T)) { - .Struct => |t| { + .@"struct" => |t| { switch (t.layout) { .auto, .@"extern" => { var s: T = undefined; @@ -20,15 +20,15 @@ pub fn readType(reader: anytype, comptime T: type, endian: std.builtin.Endian) ! .@"packed" => return @bitCast(try readType(reader, t.backing_integer.?, endian)), } }, - .Array => |t| { + .array => |t| { var s: T = undefined; for (0..t.len) |i| { s[i] = try readType(reader, t.child, endian); } return s; }, - .Int => try reader.readInt(T, endian), - .Enum => |t| @enumFromInt(try readType(reader, t.tag_type, endian)), + .int => try reader.readInt(T, endian), + .@"enum" => |t| @enumFromInt(try readType(reader, t.tag_type, endian)), else => |e| @compileError(@tagName(e)), }; } diff --git a/src/sliceToInt.zig b/src/sliceToInt.zig index fda2609b1a5cb814c9c3a00486a0e5f7d430c899..05516a3bf23cf969199e25559a37ca48b457656e 100644 --- a/src/sliceToInt.zig +++ b/src/sliceToInt.zig @@ -3,8 +3,8 @@ const string = []const u8; const extras = @import("./lib.zig"); pub fn sliceToInt(comptime T: type, comptime E: type, slice: []const E) !T { - const a = @typeInfo(T).Int.bits; - const b = @typeInfo(E).Int.bits; + const a = @typeInfo(T).int.bits; + const b = @typeInfo(E).int.bits; if (a < b * slice.len) return error.Overflow; var n: T = 0;