add generic dump function - handy for printf debugging

This commit is contained in:
Emil Lerch 2021-09-02 15:41:14 -07:00
parent 87116cb69e
commit 98b0c4127f
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -1324,6 +1324,14 @@ pub const Value = union(enum) {
}
};
pub fn dump(value: anytype) void {
var held = std.debug.getStderrMutex().acquire();
defer held.release();
const stderr = std.io.getStdErr().writer();
std.json.stringify(value, std.json.StringifyOptions{ .whitespace = null }, stderr) catch return;
}
test "Value.jsonStringify" {
{
var buffer: [10]u8 = undefined;