Currently, Zig's std.meta.Int function looks like this.
I propose the following change:
const Signedness = enum {
u,
i,
};
pub fn Int(comptime signedness: Signedness, comptime bit_count: u16) type {
return @Type(TypeInfo{
.Int = .{
.is_signed = signedness == .i,
.bits = bit_count,
},
});
}
Compare the following calls:
std.meta.Int(true, 32);
std.meta.Int(.i, 32);
std.meta.Int(false, 16);
std.meta.Int(.u, 16);
I think the proposed version looks much cleaner and closer to how one would normally write an integer type.
Note that this doesn't (and doesn't attempt to) change the TypeInfo representation of an integer and only changes the convenience std.meta API.
Yes, please! I only want one change: .unsigned and .signed
Most helpful comment
Yes, please! I only want one change:
.unsignedand.signed