-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #768 from polyadic/primary-constructor
Use Primary Constructors
- Loading branch information
Showing
34 changed files
with
139 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,14 @@ | ||
namespace Funcky.Async.Test.TestUtilities; | ||
|
||
internal sealed class OptionProducer<T> | ||
internal sealed class OptionProducer<T>(int retriesNeeded, T result) | ||
where T : notnull | ||
{ | ||
private readonly T _result; | ||
private readonly int _retriesNeeded; | ||
|
||
public OptionProducer(int retriesNeeded, T result) | ||
{ | ||
_retriesNeeded = retriesNeeded; | ||
_result = result; | ||
} | ||
|
||
public int Called { get; private set; } | ||
|
||
public ValueTask<Option<T>> ProduceAsync() | ||
{ | ||
Called += 1; | ||
|
||
return ValueTask.FromResult(Option.FromBoolean(_retriesNeeded == (Called - 1), _result)); | ||
return ValueTask.FromResult(Option.FromBoolean(retriesNeeded == (Called - 1), result)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,14 @@ | ||
namespace Funcky.Test.TestUtils; | ||
|
||
internal sealed class OptionProducer<T> | ||
internal sealed class OptionProducer<T>(int retriesNeeded, T result) | ||
where T : notnull | ||
{ | ||
private readonly T _result; | ||
private readonly int _retriesNeeded; | ||
|
||
public OptionProducer(int retriesNeeded, T result) | ||
{ | ||
_retriesNeeded = retriesNeeded; | ||
_result = result; | ||
} | ||
|
||
public int Called { get; private set; } | ||
|
||
public Option<T> Produce() | ||
{ | ||
Called += 1; | ||
|
||
return Option.FromBoolean(_retriesNeeded == (Called - 1), _result); | ||
return Option.FromBoolean(retriesNeeded == (Called - 1), result); | ||
} | ||
} |
Oops, something went wrong.