diff --git a/example/main.zig b/example/main.zig index bd9eab7..48b5d11 100644 --- a/example/main.zig +++ b/example/main.zig @@ -46,9 +46,10 @@ pub fn main(init: std.process.Init) !void { print("Pretty enum - {f}\n", .{pretty(Hello.world)}); print("Pretty enum literal - {f}\n", .{pretty(.hello_world)}); - print("\nOptionals\n", .{}); const opt_null: ?Hello = null; const opt_not_null: ?Hello = .developer; + + print("\nOptionals\n", .{}); print("Pretty optional = null - {f}\n", .{pretty(opt_null)}); print("Pretty optional = not null - {f}\n", .{pretty(opt_not_null)}); } diff --git a/pretty.zig b/pretty.zig index f3589ce..1dc0922 100644 --- a/pretty.zig +++ b/pretty.zig @@ -7,7 +7,8 @@ pub const Options = struct { show_type_names: bool = true, always_show_type_names: bool = true, - type_value_seperator: []const u8 = " = ", + field_name_type_sep: []const u8 = ": ", + type_value_sep: []const u8 = " = ", }; pub fn pretty(value: anytype) Pretty(@TypeOf(value)) { @@ -148,7 +149,7 @@ inline fn printType( if (cctx.options.show_type_names) { try rctx.write(@typeName(T)); } - try rctx.write(cctx.options.type_value_seperator); + try rctx.write(cctx.options.type_value_sep); rctx.resetColor(); } @@ -166,7 +167,12 @@ inline fn formatNull(ctx: RuntimeContext) !void { ctx.resetColor(); } -inline fn formatOptional(comptime T: type, comptime cctx: ComptimeContext, rctx: RuntimeContext, value: ?T) !void { +inline fn formatOptional( + comptime T: type, + comptime cctx: ComptimeContext, + rctx: RuntimeContext, + value: ?T, +) !void { return if (value) |val| innerFmt(T, cctx, rctx, val, .{ .dont_skip_type_name = false }) else