Skip to content

Commit

Permalink
Merge pull request #8 from 2hit-io/patch/3.0.1
Browse files Browse the repository at this point in the history
Patch/3.0.1
  • Loading branch information
wsantosdev committed Jan 13, 2024
2 parents 3afa0df + 068a5d3 commit 0429252
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 67 deletions.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions src/Choice/ChoiceT1T2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ namespace Moonad
{
public readonly struct Choice<T1, T2> : IChoice, IEquatable<Choice<T1, T2>> where T1 : notnull where T2 : notnull
{
public readonly IChoice Choosed;
public readonly IChoice Chosen;

public Choice(T1 choice) =>
Choosed = new Choice<T1>(choice);
Chosen = new Choice<T1>(choice);

public Choice(T2 choice) =>
Choosed = new Choice<T2>(choice);
Chosen = new Choice<T2>(choice);

public static implicit operator Choice<T1, T2>(T1 choice) =>
new(choice);
Expand All @@ -19,10 +19,10 @@ public static implicit operator Choice<T1, T2>(T2 choice) =>
new(choice);

public static implicit operator T1(Choice<T1, T2> choice) =>
(Choice<T1>)choice.Choosed;
(Choice<T1>)choice.Chosen;

public static implicit operator T2(Choice<T1, T2> choice) =>
(Choice<T2>)choice.Choosed;
(Choice<T2>)choice.Chosen;

public static bool operator ==(Choice<T1, T2> left, Choice<T1, T2> right) =>
left.Equals(right);
Expand All @@ -32,11 +32,11 @@ public static implicit operator T2(Choice<T1, T2> choice) =>

public bool Equals(Choice<T1, T2> other)
{
if (Choosed is Choice<T1> choice1 && other.Choosed is Choice<T1>)
return choice1.Equals(other.Choosed);
if (Chosen is Choice<T1> choice1 && other.Chosen is Choice<T1>)
return choice1.Equals(other.Chosen);

if (Choosed is Choice<T2> choice2 && other.Choosed is Choice<T2>)
return choice2.Equals(other.Choosed);
if (Chosen is Choice<T2> choice2 && other.Chosen is Choice<T2>)
return choice2.Equals(other.Chosen);

return false;
}
Expand All @@ -51,7 +51,7 @@ public override bool Equals(object? obj)

public override int GetHashCode()
{
return Choosed switch
return Chosen switch
{
Choice<T1> choice => choice.GetHashCode(),
Choice<T2> choice => choice.GetHashCode(),
Expand Down
28 changes: 14 additions & 14 deletions src/Choice/ChoiceT1T2T3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ namespace Moonad
public readonly struct Choice<T1, T2, T3> : IChoice, IEquatable<Choice<T1, T2, T3>>
where T1 : notnull where T2 : notnull where T3 : notnull
{
public readonly IChoice Choosed;
public readonly IChoice Chosen;

public Choice(T1 choice) =>
Choosed = new Choice<T1>(choice);
Chosen = new Choice<T1>(choice);

public Choice(T2 choice) =>
Choosed = new Choice<T2>(choice);
Chosen = new Choice<T2>(choice);

public Choice(T3 choice) =>
Choosed = new Choice<T3>(choice);
Chosen = new Choice<T3>(choice);

public static implicit operator Choice<T1, T2, T3>(T1 choice) =>
new(choice);
Expand All @@ -26,13 +26,13 @@ public static implicit operator Choice<T1, T2, T3>(T3 choice) =>
new(choice);

public static implicit operator T1(Choice<T1, T2, T3> choice) =>
(Choice<T1>)choice.Choosed;
(Choice<T1>)choice.Chosen;

public static implicit operator T2(Choice<T1, T2, T3> choice) =>
(Choice<T2>)choice.Choosed;
(Choice<T2>)choice.Chosen;

public static implicit operator T3(Choice<T1, T2, T3> choice) =>
(Choice<T3>)choice.Choosed;
(Choice<T3>)choice.Chosen;

public static bool operator ==(Choice<T1, T2, T3> left, Choice<T1, T2, T3> right) =>
left.Equals(right);
Expand All @@ -42,14 +42,14 @@ public static implicit operator T3(Choice<T1, T2, T3> choice) =>

public bool Equals(Choice<T1, T2, T3> other)
{
if (Choosed is Choice<T1> choice1 && other.Choosed is Choice<T1>)
return choice1.Equals(other.Choosed);
if (Chosen is Choice<T1> choice1 && other.Chosen is Choice<T1>)
return choice1.Equals(other.Chosen);

if (Choosed is Choice<T2> choice2 && other.Choosed is Choice<T2>)
return choice2.Equals(other.Choosed);
if (Chosen is Choice<T2> choice2 && other.Chosen is Choice<T2>)
return choice2.Equals(other.Chosen);

if (Choosed is Choice<T3> choice3 && other.Choosed is Choice<T3>)
return choice3.Equals(other.Choosed);
if (Chosen is Choice<T3> choice3 && other.Chosen is Choice<T3>)
return choice3.Equals(other.Chosen);

return false;
}
Expand All @@ -64,7 +64,7 @@ public override bool Equals(object? obj)

public override int GetHashCode()
{
return Choosed switch
return Chosen switch
{
Choice<T1> choice => choice.GetHashCode(),
Choice<T2> choice => choice.GetHashCode(),
Expand Down
36 changes: 18 additions & 18 deletions src/Choice/ChoiceT1T2T3T4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ namespace Moonad
public readonly struct Choice<T1, T2, T3, T4> : IChoice, IEquatable<Choice<T1, T2, T3, T4>>
where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull
{
public readonly IChoice Choosed;
public readonly IChoice Chosen;

public Choice(T1 choice) =>
Choosed = new Choice<T1>(choice);
Chosen = new Choice<T1>(choice);

public Choice(T2 choice) =>
Choosed = new Choice<T2>(choice);
Chosen = new Choice<T2>(choice);

public Choice(T3 choice) =>
Choosed = new Choice<T3>(choice);
Chosen = new Choice<T3>(choice);

public Choice(T4 choice) =>
Choosed = new Choice<T4>(choice);
Chosen = new Choice<T4>(choice);

public static implicit operator Choice<T1, T2, T3, T4>(T1 choice) =>
new(choice);
Expand All @@ -32,16 +32,16 @@ public static implicit operator Choice<T1, T2, T3, T4>(T4 choice) =>
new(choice);

public static implicit operator T1(Choice<T1, T2, T3, T4> choice) =>
(Choice<T1>)choice.Choosed;
(Choice<T1>)choice.Chosen;

public static implicit operator T2(Choice<T1, T2, T3, T4> choice) =>
(Choice<T2>)choice.Choosed;
(Choice<T2>)choice.Chosen;

public static implicit operator T3(Choice<T1, T2, T3, T4> choice) =>
(Choice<T3>)choice.Choosed;
(Choice<T3>)choice.Chosen;

public static implicit operator T4(Choice<T1, T2, T3, T4> choice) =>
(Choice<T4>)choice.Choosed;
(Choice<T4>)choice.Chosen;

public static bool operator ==(Choice<T1, T2, T3, T4> left, Choice<T1, T2, T3, T4> right) =>
left.Equals(right);
Expand All @@ -51,17 +51,17 @@ public static implicit operator T4(Choice<T1, T2, T3, T4> choice) =>

public bool Equals(Choice<T1, T2, T3, T4> other)
{
if (Choosed is Choice<T1> choice1 && other.Choosed is Choice<T1>)
return choice1.Equals(other.Choosed);
if (Chosen is Choice<T1> choice1 && other.Chosen is Choice<T1>)
return choice1.Equals(other.Chosen);

if (Choosed is Choice<T2> choice2 && other.Choosed is Choice<T2>)
return choice2.Equals(other.Choosed);
if (Chosen is Choice<T2> choice2 && other.Chosen is Choice<T2>)
return choice2.Equals(other.Chosen);

if (Choosed is Choice<T3> choice3 && other.Choosed is Choice<T3>)
return choice3.Equals(other.Choosed);
if (Chosen is Choice<T3> choice3 && other.Chosen is Choice<T3>)
return choice3.Equals(other.Chosen);

if (Choosed is Choice<T4> choice4 && other.Choosed is Choice<T4>)
return choice4.Equals(other.Choosed);
if (Chosen is Choice<T4> choice4 && other.Chosen is Choice<T4>)
return choice4.Equals(other.Chosen);

return false;
}
Expand All @@ -76,7 +76,7 @@ public override bool Equals(object? obj)

public override int GetHashCode()
{
return Choosed switch
return Chosen switch
{
Choice<T1> choice => choice.GetHashCode(),
Choice<T2> choice => choice.GetHashCode(),
Expand Down
44 changes: 22 additions & 22 deletions src/Choice/ChoiceT1T2T3T4T5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ namespace Moonad
public readonly struct Choice<T1, T2, T3, T4, T5> : IChoice, IEquatable<Choice<T1, T2, T3, T4, T5>>
where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull where T5 : notnull
{
public readonly IChoice Choosed;
public readonly IChoice Chosen;

public Choice(T1 choice) =>
Choosed = new Choice<T1>(choice);
Chosen = new Choice<T1>(choice);

public Choice(T2 choice) =>
Choosed = new Choice<T2>(choice);
Chosen = new Choice<T2>(choice);

public Choice(T3 choice) =>
Choosed = new Choice<T3>(choice);
Chosen = new Choice<T3>(choice);

public Choice(T4 choice) =>
Choosed = new Choice<T4>(choice);
Chosen = new Choice<T4>(choice);

public Choice(T5 choice) =>
Choosed = new Choice<T5>(choice);
Chosen = new Choice<T5>(choice);

public static implicit operator Choice<T1, T2, T3, T4, T5>(T1 choice) =>
new(choice);
Expand All @@ -38,19 +38,19 @@ public static implicit operator Choice<T1, T2, T3, T4, T5>(T5 choice) =>
new(choice);

public static implicit operator T1(Choice<T1, T2, T3, T4, T5> choice) =>
(Choice<T1>)choice.Choosed;
(Choice<T1>)choice.Chosen;

public static implicit operator T2(Choice<T1, T2, T3, T4, T5> choice) =>
(Choice<T2>)choice.Choosed;
(Choice<T2>)choice.Chosen;

public static implicit operator T3(Choice<T1, T2, T3, T4, T5> choice) =>
(Choice<T3>)choice.Choosed;
(Choice<T3>)choice.Chosen;

public static implicit operator T4(Choice<T1, T2, T3, T4, T5> choice) =>
(Choice<T4>)choice.Choosed;
(Choice<T4>)choice.Chosen;

public static implicit operator T5(Choice<T1, T2, T3, T4, T5> choice) =>
(Choice<T5>)choice.Choosed;
(Choice<T5>)choice.Chosen;

public static bool operator ==(Choice<T1, T2, T3, T4, T5> left, Choice<T1, T2, T3, T4, T5> right) =>
left.Equals(right);
Expand All @@ -60,20 +60,20 @@ public static implicit operator T5(Choice<T1, T2, T3, T4, T5> choice) =>

public bool Equals(Choice<T1, T2, T3, T4, T5> other)
{
if (Choosed is Choice<T1> choice1 && other.Choosed is Choice<T1>)
return choice1.Equals(other.Choosed);
if (Chosen is Choice<T1> choice1 && other.Chosen is Choice<T1>)
return choice1.Equals(other.Chosen);

if (Choosed is Choice<T2> choice2 && other.Choosed is Choice<T2>)
return choice2.Equals(other.Choosed);
if (Chosen is Choice<T2> choice2 && other.Chosen is Choice<T2>)
return choice2.Equals(other.Chosen);

if (Choosed is Choice<T3> choice3 && other.Choosed is Choice<T3>)
return choice3.Equals(other.Choosed);
if (Chosen is Choice<T3> choice3 && other.Chosen is Choice<T3>)
return choice3.Equals(other.Chosen);

if (Choosed is Choice<T4> choice4 && other.Choosed is Choice<T4>)
return choice4.Equals(other.Choosed);
if (Chosen is Choice<T4> choice4 && other.Chosen is Choice<T4>)
return choice4.Equals(other.Chosen);

if (Choosed is Choice<T5> choice5 && other.Choosed is Choice<T5>)
return choice5.Equals(other.Choosed);
if (Chosen is Choice<T5> choice5 && other.Chosen is Choice<T5>)
return choice5.Equals(other.Chosen);

return false;
}
Expand All @@ -88,7 +88,7 @@ public override bool Equals(object? obj)

public override int GetHashCode()
{
return Choosed switch
return Chosen switch
{
Choice<T1> choice => choice.GetHashCode(),
Choice<T2> choice => choice.GetHashCode(),
Expand Down
6 changes: 3 additions & 3 deletions test/Choice/ChoiceT1T2.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void ImplictT1Conversion()
Choice<int, string> choice = expected;

//Assert
Assert.True(choice.Choosed is Choice<int>);
Assert.True(choice.Chosen is Choice<int>);
Assert.True(expected == choice);
}

Expand Down Expand Up @@ -59,9 +59,9 @@ Choice<int, string> Choose(bool returnInt) =>
Choice<int, string> choice2 = Choose(false);

//Assert
Assert.IsType<Choice<int>>(choice1.Choosed);
Assert.IsType<Choice<int>>(choice1.Chosen);
Assert.Equal<int>(asInt, choice1);
Assert.IsType<Choice<string>>(choice2.Choosed);
Assert.IsType<Choice<string>>(choice2.Chosen);
Assert.Equal(asString, choice2);
}
}
Expand Down

0 comments on commit 0429252

Please sign in to comment.