std: remove meta.trait
In general, I don't like the idea of std.meta.trait, and so I am providing some guidance by deleting the entire namespace from the standard library and compiler codebase. My main criticism is that it's overcomplicated machinery that bloats compile times and is ultimately unnecessary given the existence of Zig's strong type system and reference traces. Users who want this can create a third party package that provides this functionality. closes #18051
This commit is contained in:
@@ -451,14 +451,14 @@ pub fn WriteStream(
|
||||
}
|
||||
},
|
||||
.Enum, .EnumLiteral => {
|
||||
if (comptime std.meta.trait.hasFn("jsonStringify")(T)) {
|
||||
if (std.meta.hasFn(T, "jsonStringify")) {
|
||||
return value.jsonStringify(self);
|
||||
}
|
||||
|
||||
return self.stringValue(@tagName(value));
|
||||
},
|
||||
.Union => {
|
||||
if (comptime std.meta.trait.hasFn("jsonStringify")(T)) {
|
||||
if (std.meta.hasFn(T, "jsonStringify")) {
|
||||
return value.jsonStringify(self);
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ pub fn WriteStream(
|
||||
}
|
||||
},
|
||||
.Struct => |S| {
|
||||
if (comptime std.meta.trait.hasFn("jsonStringify")(T)) {
|
||||
if (std.meta.hasFn(T, "jsonStringify")) {
|
||||
return value.jsonStringify(self);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user