| ... | ... | @@ -737,13 +737,15 @@ test TagPayload { |
| 737 | 737 | try testing.expect(MovedEvent == @TypeOf(e.Moved)); |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | | /// Compares two of any type for equality. Containers are compared on a field-by-field basis, |
| 741 | | /// where possible. Pointers are not followed. |
| 740 | /// Compares two of any type for equality. Containers that do not support comparison |
| 741 | /// on their own are compared on a field-by-field basis. Pointers are not followed. |
| 742 | 742 | pub fn eql(a: anytype, b: @TypeOf(a)) bool { |
| 743 | 743 | const T = @TypeOf(a); |
| 744 | 744 | |
| 745 | 745 | switch (@typeInfo(T)) { |
| 746 | 746 | .@"struct" => |info| { |
| 747 | if (info.layout == .@"packed") return a == b; |
| 748 | |
| 747 | 749 | inline for (info.fields) |field_info| { |
| 748 | 750 | if (!eql(@field(a, field_info.name), @field(b, field_info.name))) return false; |
| 749 | 751 | } |