Skip to content

Commit

Permalink
Implement IEquatable on Optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
grokys committed Nov 21, 2019
1 parent 8b1efc5 commit 55eea62
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Avalonia.Base/Data/Optional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Avalonia.Data
/// conversion from <typeparamref name="T"/>
/// - For an missing value, use <see cref="Empty"/> or simply `default`
/// </remarks>
public readonly struct Optional<T>
public readonly struct Optional<T> : IEquatable<Optional<T>>
{
private readonly T _value;

Expand Down Expand Up @@ -50,6 +50,9 @@ public Optional(T value)
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Optional<T> o && this == o;

/// <inheritdoc/>
public bool Equals(Optional<T> other) => this == other;

/// <inheritdoc/>
public override int GetHashCode() => HasValue ? Value!.GetHashCode() : 0;

Expand Down

0 comments on commit 55eea62

Please sign in to comment.