refactor: made equality operators consistent in primitives & added missing ones

This commit is contained in:
2025-06-27 12:00:46 +03:00
parent fa1614f238
commit da5f31f9d7
8 changed files with 29 additions and 11 deletions

View File

@@ -21,6 +21,9 @@ public readonly struct Line2DEquation(float slope, float offsetY)
/// </summary>
public readonly float OffsetY = offsetY;
public static bool operator ==(Line2DEquation left, Line2DEquation right) => left.Slope == right.Slope && left.OffsetY == right.OffsetY;
public static bool operator !=(Line2DEquation left, Line2DEquation right) => left.Slope != right.Slope || left.OffsetY != right.OffsetY;
/// <summary>
/// Resolves the Y coordinate for a given X coordinate using the <see cref="Line2DEquation"/>.
/// </summary>
@@ -44,7 +47,7 @@ public readonly struct Line2DEquation(float slope, float offsetY)
/// </summary>
/// <param name="obj">The object to compare with the current <see cref="Line2DEquation"/>.</param>
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Line2DEquation"/>; otherwise, <see cref="false"/>.</returns>
public override bool Equals(object? obj) => obj is Line2DEquation lineEquation && Slope.Equals(lineEquation.Slope) && OffsetY.Equals(lineEquation.OffsetY);
public override bool Equals(object? obj) => obj is Line2DEquation lineEquation && this == lineEquation;
/// <summary>
/// Generates a hash code for the <see cref="Line2DEquation"/>.