json: give enums a default stringify implementation

This commit is contained in:
Evin Yulo
2023-06-27 14:28:17 -04:00
committed by Andrew Kelley
parent b26fa4ec4b
commit ba6e5e65a0
2 changed files with 10 additions and 1 deletions

View File

@@ -167,7 +167,7 @@ pub fn stringify(
return value.jsonStringify(options, out_stream);
}
@compileError("Unable to stringify enum '" ++ @typeName(T) ++ "'");
return try encodeJsonString(@tagName(value), options, out_stream);
},
.Union => {
if (comptime std.meta.trait.hasFn("jsonStringify")(T)) {