~alva/zig-bare

e90185008d7efbbe3a438a7dd03ea82f1c28c269 — ugla a month ago a09873b
Small cleanup of float reading
1 files changed, 3 insertions(+), 4 deletions(-)

M src/bare.zig
M src/bare.zig => src/bare.zig +3 -4
@@ 92,10 92,9 @@ pub const Reader = struct {
    }

    fn readFloat(self: *Self, comptime T: type, reader: anytype) !T {
        const type_info = @typeInfo(T);
        return switch (type_info.Float.bits) {
            32 => @bitCast(T, try reader.readIntLittle(u32)),
            64 => @bitCast(T, try reader.readIntLittle(u64)),
        const bits = @typeInfo(T).Float.bits;
        return switch (bits) {
            32, 64 => @bitCast(T, try reader.readIntLittle(meta.Int(.unsigned, bits))),
            else => @compileError("unsupported float type " ++ @typeName(T)),
        };
    }