Skip to content

Commit

Permalink
Merge pull request #423 from ProphetLamb/fix_unessesary_shadowing
Browse files Browse the repository at this point in the history
Rework: Fix unessesary shadowing
  • Loading branch information
vkhorikov authored Jul 11, 2022
2 parents 7a67d88 + a197abd commit dc277d5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions CSharpFunctionalExtensions/Maybe/Maybe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ private Maybe(T value)
_isValueSet = true;
_value = value;
}

public static implicit operator Maybe<T>(T value)
{
if (value?.GetType() == typeof(Maybe<T>))
if (value is Maybe<T> m)
{
return (Maybe<T>)(object)value;
return m;
}

return new Maybe<T>(value);
return EqualityComparer<T>.Default.Equals(default, value) ? default : new Maybe<T>(value);
}

public static implicit operator Maybe<T>(Maybe value) => None;
Expand Down Expand Up @@ -90,7 +89,7 @@ public static Maybe<T> From(T obj)
{
return maybe.Equals(other);
}

public static bool operator !=(Maybe<T> maybe, object other)
{
return !(maybe == other);
Expand Down

0 comments on commit dc277d5

Please sign in to comment.