A pretty printer for zig
zig

custom inline printing

altagos.dev 0c6719d7 aa04716e

verified
+9 -2
+9 -2
pretty.zig
··· 208 209 pub const InnerFmtOptions = struct { 210 skip_type_name: bool = !default_options.show_type_names, 211 }; 212 213 fn innerFmt( ··· 222 if (!opts.skip_type_name) 223 try printType(T, ctx, run, value); 224 225 - if (std.meta.hasMethod(T, "pretty")) { 226 - return value.pretty(ctx, run); 227 } 228 229 return switch (info) {
··· 208 209 pub const InnerFmtOptions = struct { 210 skip_type_name: bool = !default_options.show_type_names, 211 + force_inline: bool = false, 212 }; 213 214 fn innerFmt( ··· 223 if (!opts.skip_type_name) 224 try printType(T, ctx, run, value); 225 226 + if (ctx.options.struct_inline or opts.force_inline) { 227 + if (std.meta.hasMethod(T, "prettyInline")) { 228 + return value.prettyInline(ctx, run); 229 + } 230 + } else { 231 + if (std.meta.hasMethod(T, "pretty")) { 232 + return value.pretty(ctx, run); 233 + } 234 } 235 236 return switch (info) {