| ... | ... | @@ -983,13 +983,13 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { |
| 983 | 983 | else => false, // TODO can we know if it's true for some of these types ? |
| 984 | 984 | |
| 985 | 985 | .@"anyframe", |
| 986 | | .@"enum", |
| 987 | 986 | .error_set, |
| 988 | 987 | .@"fn", |
| 989 | 988 | => true, |
| 990 | 989 | |
| 991 | 990 | .bool => false, |
| 992 | 991 | |
| 992 | .@"enum" => |info| hasUniqueRepresentation(info.tag_type), |
| 993 | 993 | .int => |info| @sizeOf(T) * 8 == info.bits, |
| 994 | 994 | |
| 995 | 995 | .pointer => |info| info.size != .slice, |
| ... | ... | @@ -1089,9 +1089,11 @@ test hasUniqueRepresentation { |
| 1089 | 1089 | |
| 1090 | 1090 | inline for ([_]type{ i0, u8, i16, u32, i64 }) |T| { |
| 1091 | 1091 | try testing.expect(hasUniqueRepresentation(T)); |
| 1092 | try testing.expect(hasUniqueRepresentation(enum(T) { _ })); |
| 1092 | 1093 | } |
| 1093 | 1094 | inline for ([_]type{ i1, u9, i17, u33, i24 }) |T| { |
| 1094 | 1095 | try testing.expect(!hasUniqueRepresentation(T)); |
| 1096 | try testing.expect(!hasUniqueRepresentation(enum(T) { _ })); |
| 1095 | 1097 | } |
| 1096 | 1098 | |
| 1097 | 1099 | try testing.expect(hasUniqueRepresentation(*u8)); |