Skip to content

Commit cc403f6

Browse files
Add documentation for new equality members
1 parent cbf3d40 commit cc403f6

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/Hamlet/OptionOfT.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,58 @@ public bool TryGetValue(out T value)
6767
/// <param name="value">The <see cref="NoneOption"/> to convert.</param>
6868
public static implicit operator Option<T>(NoneOption value) => default;
6969

70+
/// <summary>
71+
/// Determines wether two specified options are equal.
72+
/// </summary>
73+
/// <param name="a">The first option to compare.</param>
74+
/// <param name="b">The second option to compare.</param>
75+
/// <returns>true if the options are equal, false otherwise.</returns>
76+
/// <remarks>The equality semantics are the same as for <see cref="Equals(Option{T})"/></remarks>
7077
public static bool operator ==(Option<T> a, Option<T> b) => a.Equals(b);
7178

79+
/// <summary>
80+
/// Determines wether two specified options are different.
81+
/// </summary>
82+
/// <param name="a">The first option to compare.</param>
83+
/// <param name="b">The second option to compare.</param>
84+
/// <returns>true if the options are different, false otherwise.</returns>
85+
/// <remarks>The equality semantics are the same as for <see cref="Equals(Option{T})"/></remarks>
7286
public static bool operator !=(Option<T> a, Option<T> b) => !(a == b);
7387

88+
/// <summary>
89+
/// Determines wether the specified option and value are equal.
90+
/// </summary>
91+
/// <param name="option">The option to compare.</param>
92+
/// <param name="value">The value to compare.</param>
93+
/// <returns>true if <c>option</c> has a value equal to <c>value</c>, false otherwise.</returns>
94+
/// <remarks>Always returns false if the option is <c>None</c>.</remarks>
7495
public static bool operator ==(Option<T> option, T value) => option.Equals(value);
7596

97+
/// <summary>
98+
/// Determines wether the specified option and value are different.
99+
/// </summary>
100+
/// <param name="option">The option to compare.</param>
101+
/// <param name="value">The value to compare.</param>
102+
/// <returns>true if <c>option</c> is <c>None</c> or has a value different from <c>value</c>, false otherwise.</returns>
103+
/// <remarks>Always returns true if the option is <c>None</c>.</remarks>
76104
public static bool operator !=(Option<T> option, T value) => !(option == value);
77105

106+
/// <summary>
107+
/// Determines wether the specified value and option are equal.
108+
/// </summary>
109+
/// <param name="value">The value to compare.</param>
110+
/// <param name="option">The option to compare.</param>
111+
/// <returns>true if <c>option</c> has a value equal to <c>value</c>, false otherwise.</returns>
112+
/// <remarks>Always returns false if the option is <c>None</c>.</remarks>
78113
public static bool operator ==(T value, Option<T> option) => option == value;
79114

115+
/// <summary>
116+
/// Determines wether the specified value and option are different.
117+
/// </summary>
118+
/// <param name="value">The value to compare.</param>
119+
/// <param name="option">The option to compare.</param>
120+
/// <returns>true if <c>option</c> is <c>None</c> or has a value different from <c>value</c>, false otherwise.</returns>
121+
/// <remarks>Always returns true if the option is <c>None</c>.</remarks>
80122
public static bool operator !=(T value, Option<T> option) => option != value;
81123

82124
/// <summary>
@@ -107,6 +149,11 @@ public bool Equals(Option<T> other)
107149
}
108150
}
109151

152+
/// <summary>
153+
/// Determines whether the specified value is equal to the current option.
154+
/// </summary>
155+
/// <param name="value">The value to compare with the current option.</param>
156+
/// <returns>True if the current option is <c>Some</c> and has a value equal to <c>value</c>, false otherwise.</returns>
110157
public bool Equals(T value)
111158
{
112159
return IsSome && EqualityComparer<T>.Default.Equals(value, Value);

0 commit comments

Comments
 (0)