Skip to content

Commit f136d6b

Browse files
author
jules
committed
fix: update references to std.builtin.Type via @typeinfo to v0.14 format
fix: update references to std.builtin.Type via @typeinfo to v0.14 format
1 parent 7b2ee0e commit f136d6b

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/float.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn packFloat(writer: anytype, comptime T: type, value_or_maybe_null: T) !voi
3232

3333
comptime var TargetType: type = undefined;
3434
const type_info = @typeInfo(Type);
35-
switch (type_info.Float.bits) {
35+
switch (type_info.float.bits) {
3636
0...32 => {
3737
try writer.writeByte(hdrs.FLOAT32);
3838
TargetType = f32;
@@ -88,10 +88,10 @@ const packed_float64_inf = [_]u8{ 0xcb, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00
8888

8989
const float_types = [_]type{ f16, f32, f64 };
9090

91-
fn minFloatType(comptime T1: type, comptime T2: type) type {
91+
fn MinFloatType(comptime T1: type, comptime T2: type) type {
9292
const ti1 = @typeInfo(T1);
9393
const ti2 = @typeInfo(T2);
94-
return std.meta.Float(@min(ti1.Float.bits, ti2.Float.bits));
94+
return std.meta.Float(@min(ti1.float.bits, ti2.float.bits));
9595
}
9696

9797
test "readFloat: null" {
@@ -105,31 +105,31 @@ test "readFloat: float32 (zero)" {
105105
inline for (float_types) |T| {
106106
var stream = std.io.fixedBufferStream(&packed_float32_zero);
107107
const value = try unpackFloat(stream.reader(), T);
108-
try std.testing.expectApproxEqAbs(0.0, value, std.math.floatEpsAt(minFloatType(T, f32), @floatCast(value)));
108+
try std.testing.expectApproxEqAbs(0.0, value, std.math.floatEpsAt(MinFloatType(T, f32), @floatCast(value)));
109109
}
110110
}
111111

112112
test "readFloat: float64 (zero)" {
113113
inline for (float_types) |T| {
114114
var stream = std.io.fixedBufferStream(&packed_float64_zero);
115115
const value = try unpackFloat(stream.reader(), T);
116-
try std.testing.expectApproxEqAbs(0.0, value, std.math.floatEpsAt(minFloatType(T, f64), @floatCast(value)));
116+
try std.testing.expectApproxEqAbs(0.0, value, std.math.floatEpsAt(MinFloatType(T, f64), @floatCast(value)));
117117
}
118118
}
119119

120120
test "readFloat: float32 (pi)" {
121121
inline for (float_types) |T| {
122122
var stream = std.io.fixedBufferStream(&packed_float32_pi);
123123
const value = try unpackFloat(stream.reader(), T);
124-
try std.testing.expectApproxEqAbs(std.math.pi, value, std.math.floatEpsAt(minFloatType(T, f32), @floatCast(value)));
124+
try std.testing.expectApproxEqAbs(std.math.pi, value, std.math.floatEpsAt(MinFloatType(T, f32), @floatCast(value)));
125125
}
126126
}
127127

128128
test "readFloat: float64 (pi)" {
129129
inline for (float_types) |T| {
130130
var stream = std.io.fixedBufferStream(&packed_float64_pi);
131131
const value = try unpackFloat(stream.reader(), T);
132-
try std.testing.expectApproxEqAbs(std.math.pi, value, std.math.floatEpsAt(minFloatType(T, f64), @floatCast(value)));
132+
try std.testing.expectApproxEqAbs(std.math.pi, value, std.math.floatEpsAt(MinFloatType(T, f64), @floatCast(value)));
133133
}
134134
}
135135

src/union.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ fn strPrefix(src: []const u8, len: usize) []const u8 {
5050

5151
pub fn packUnionAsMap(writer: anytype, comptime T: type, value: T, opts: UnionAsMapOptions) !void {
5252
const type_info = @typeInfo(T);
53-
const fields = type_info.Union.fields;
53+
const fields = type_info.@"union".fields;
5454

55-
const TagType = @typeInfo(T).Union.tag_type.?;
55+
const TagType = @typeInfo(T).@"union".tag_type.?;
5656

5757
try packMapHeader(writer, 1);
5858

@@ -79,7 +79,7 @@ pub fn packUnion(writer: anytype, comptime T: type, value_or_maybe_null: T) !voi
7979
const Type = @TypeOf(value);
8080
const type_info = @typeInfo(Type);
8181

82-
if (type_info != .Union) {
82+
if (type_info != .@"union") {
8383
@compileError("Expected union type");
8484
}
8585

@@ -92,7 +92,7 @@ pub fn packUnion(writer: anytype, comptime T: type, value_or_maybe_null: T) !voi
9292
}
9393

9494
pub fn unpackUnionAsMap(reader: anytype, allocator: std.mem.Allocator, comptime T: type, opts: UnionAsMapOptions) !T {
95-
const len = if (@typeInfo(T) == .Optional)
95+
const len = if (@typeInfo(T) == .optional)
9696
try unpackMapHeader(reader, ?u16) orelse return null
9797
else
9898
try unpackMapHeader(reader, u16);
@@ -103,7 +103,7 @@ pub fn unpackUnionAsMap(reader: anytype, allocator: std.mem.Allocator, comptime
103103

104104
const Type = NonOptional(T);
105105
const type_info = @typeInfo(Type);
106-
const fields = type_info.Union.fields;
106+
const fields = type_info.@"union".fields;
107107

108108
var field_name_buffer: [256]u8 = undefined;
109109

0 commit comments

Comments
 (0)