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 Projection1D(float min, float max)
/// </summary>
public readonly float Max = max;
public static bool operator ==(Projection1D left, Projection1D right) => left.Min == right.Min && left.Max == right.Max;
public static bool operator !=(Projection1D left, Projection1D right) => left.Min != right.Min || left.Max != right.Max;
/// <summary>
/// Checks if two projections overlap.
/// </summary>
@@ -86,7 +89,7 @@ public readonly struct Projection1D(float min, float max)
/// </summary>
/// <param name="obj">The object to compare with the current <see cref="Projection1D"/>.</param>
/// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Projection1D"/>; otherwise, <see cref="false"/>.</returns>
public override bool Equals(object? obj) => obj is Projection1D projection1D && Min.Equals(projection1D.Min) && Max.Equals(projection1D.Max);
public override bool Equals(object? obj) => obj is Projection1D projection1D && this == projection1D;
/// <summary>
/// Generates a hash code for the <see cref="Projection1D"/>.