Browse Source

Implement IEquatable on Optional.

pull/3287/head
Steven Kirk 7 years ago
parent
commit
55eea624ee
  1. 5
      src/Avalonia.Base/Data/Optional.cs

5
src/Avalonia.Base/Data/Optional.cs

@ -20,7 +20,7 @@ namespace Avalonia.Data
/// conversion from <typeparamref name="T"/> /// conversion from <typeparamref name="T"/>
/// - For an missing value, use <see cref="Empty"/> or simply `default` /// - For an missing value, use <see cref="Empty"/> or simply `default`
/// </remarks> /// </remarks>
public readonly struct Optional<T> public readonly struct Optional<T> : IEquatable<Optional<T>>
{ {
private readonly T _value; private readonly T _value;
@ -50,6 +50,9 @@ namespace Avalonia.Data
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is Optional<T> o && this == o; public override bool Equals(object obj) => obj is Optional<T> o && this == o;
/// <inheritdoc/>
public bool Equals(Optional<T> other) => this == other;
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() => HasValue ? Value!.GetHashCode() : 0; public override int GetHashCode() => HasValue ? Value!.GetHashCode() : 0;

Loading…
Cancel
Save