From cc403f653a24b33302a84a6439741ea649627ee6 Mon Sep 17 00:00:00 2001 From: Thomas Levesque Date: Fri, 15 Feb 2019 23:56:20 +0100 Subject: [PATCH] Add documentation for new equality members --- src/Hamlet/OptionOfT.cs | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/Hamlet/OptionOfT.cs b/src/Hamlet/OptionOfT.cs index 37c0fd4..93a58ec 100644 --- a/src/Hamlet/OptionOfT.cs +++ b/src/Hamlet/OptionOfT.cs @@ -67,16 +67,58 @@ public bool TryGetValue(out T value) /// The to convert. public static implicit operator Option(NoneOption value) => default; + /// + /// Determines wether two specified options are equal. + /// + /// The first option to compare. + /// The second option to compare. + /// true if the options are equal, false otherwise. + /// The equality semantics are the same as for public static bool operator ==(Option a, Option b) => a.Equals(b); + /// + /// Determines wether two specified options are different. + /// + /// The first option to compare. + /// The second option to compare. + /// true if the options are different, false otherwise. + /// The equality semantics are the same as for public static bool operator !=(Option a, Option b) => !(a == b); + /// + /// Determines wether the specified option and value are equal. + /// + /// The option to compare. + /// The value to compare. + /// true if option has a value equal to value, false otherwise. + /// Always returns false if the option is None. public static bool operator ==(Option option, T value) => option.Equals(value); + /// + /// Determines wether the specified option and value are different. + /// + /// The option to compare. + /// The value to compare. + /// true if option is None or has a value different from value, false otherwise. + /// Always returns true if the option is None. public static bool operator !=(Option option, T value) => !(option == value); + /// + /// Determines wether the specified value and option are equal. + /// + /// The value to compare. + /// The option to compare. + /// true if option has a value equal to value, false otherwise. + /// Always returns false if the option is None. public static bool operator ==(T value, Option option) => option == value; + /// + /// Determines wether the specified value and option are different. + /// + /// The value to compare. + /// The option to compare. + /// true if option is None or has a value different from value, false otherwise. + /// Always returns true if the option is None. public static bool operator !=(T value, Option option) => option != value; /// @@ -107,6 +149,11 @@ public bool Equals(Option other) } } + /// + /// Determines whether the specified value is equal to the current option. + /// + /// The value to compare with the current option. + /// True if the current option is Some and has a value equal to value, false otherwise. public bool Equals(T value) { return IsSome && EqualityComparer.Default.Equals(value, Value);