| ... | @@ -1129,6 +1129,15 @@ pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool { | ... | @@ -1129,6 +1129,15 @@ pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool { |
| 1129 | return @typeInfo(@TypeOf(@field(T, name))) == .Fn; | 1129 | return @typeInfo(@TypeOf(@field(T, name))) == .Fn; |
| 1130 | } | 1130 | } |
| 1131 | | 1131 | |
| | 1132 | /// Returns true if a type has a `name` method; `false` otherwise. |
| | 1133 | /// Result is always comptime-known. |
| | 1134 | pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool { |
| | 1135 | return switch (@typeInfo(T)) { |
| | 1136 | .Pointer => |P| hasFn(P.child, name), |
| | 1137 | else => hasFn(T, name), |
| | 1138 | }; |
| | 1139 | } |
| | 1140 | |
| 1132 | /// True if every value of the type `T` has a unique bit pattern representing it. | 1141 | /// True if every value of the type `T` has a unique bit pattern representing it. |
| 1133 | /// In other words, `T` has no unused bits and no padding. | 1142 | /// In other words, `T` has no unused bits and no padding. |
| 1134 | /// Result is always comptime-known. | 1143 | /// Result is always comptime-known. |