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