tangled
alpha
login
or
join now
altagos.dev
/
pretty
0
fork
atom
A pretty printer for zig
zig
0
fork
atom
overview
issues
pulls
pipelines
use @typeName(T) for printing type names
altagos.dev
1 month ago
523ab221
85e3cdf9
verified
This commit was signed with the committer's
known signature
.
altagos.dev
SSH Key Fingerprint:
SHA256:UbTjEcCZlc6GzQWLCuDK3D//HESWD2xFPkzue9XMras=
+2
-16
1 changed file
expand all
collapse all
unified
split
pretty.zig
+2
-16
pretty.zig
···
97
97
rctx: RuntimeContext,
98
98
) error{WriteFailed}!void {
99
99
const info = @typeInfo(T);
100
100
-
try printType(T, cctx, rctx, info);
100
100
+
try printType(T, cctx, rctx);
101
101
102
102
return switch (info) {
103
103
.bool => formatBool(rctx, value),
···
122
122
comptime T: type,
123
123
comptime cctx: ComptimeContext,
124
124
rctx: RuntimeContext,
125
125
-
comptime info: std.builtin.Type,
126
125
) error{WriteFailed}!void {
127
126
if (cctx.depth != 0 or cctx.options.always_show_type_names) {
128
127
rctx.setColor(.dim);
129
128
130
129
if (cctx.options.show_type_names) {
131
131
-
switch (info) {
132
132
-
.bool => try rctx.write("bool"),
133
133
-
.comptime_int => try rctx.write("comptime_int"),
134
134
-
.comptime_float => try rctx.write("comptime_float"),
135
135
-
.int => |int| try rctx.print(
136
136
-
"{s}{}",
137
137
-
.{ if (int.signedness == .signed) "i" else "u", int.bits },
138
138
-
),
139
139
-
.float => |float| try rctx.print("f{}", .{float.bits}),
140
140
-
.enum_literal => try rctx.write("enum literal"),
141
141
-
.@"enum" => try rctx.write(@typeName(T)),
142
142
-
else => try rctx.print("missing type {}", .{info}),
143
143
-
}
130
130
+
try rctx.write(@typeName(T));
144
131
}
145
145
-
146
132
try rctx.write(cctx.options.type_value_seperator);
147
133
148
134
rctx.resetColor();