Skip to content

Commit

Permalink
Merge pull request #45 from nenoNaninu/change_point2_to_record_struct
Browse files Browse the repository at this point in the history
change Point2 to record struct
nenoNaninu authored Jun 2, 2022

Verified

This commit was signed with the committer’s verified signature. The key has expired.
danielleadams Danielle Adams
2 parents 531fa0e + bcb35ed commit 4a13a54
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions HomographySharp/Point2.cs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

namespace HomographySharp;

public readonly struct Point2<T> : IEquatable<Point2<T>>
public readonly record struct Point2<T> : IEquatable<Point2<T>>
where T : unmanaged, IEquatable<T>
{
public readonly T X;
@@ -13,26 +13,4 @@ public Point2(T x, T y)
X = x;
Y = y;
}

public bool Equals(Point2<T> other)
{
return X.Equals(other.X) && Y.Equals(other.Y);
}

public override bool Equals(object? obj)
{
return obj is Point2<T> other && Equals(other);
}

public override int GetHashCode()
{
#if NETSTANDARD2_0
return X.GetHashCode() ^ Y.GetHashCode();
#else
return HashCode.Combine(X, Y);
#endif
}

public static bool operator ==(Point2<T> a, Point2<T> b) => a.Equals(b);
public static bool operator !=(Point2<T> a, Point2<T> b) => !a.Equals(b);
}

0 comments on commit 4a13a54

Please sign in to comment.