-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace OsuCollectionDownloader.Objects; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
internal readonly record struct Result<TValue>(TValue Value, Exception Error) | ||
{ | ||
internal bool IsSucessfulWithValue => IsSuccessful && HasValue; | ||
|
||
private readonly bool IsSuccessful => Error is null; | ||
namespace OsuCollectionDownloader.Objects; | ||
|
||
private readonly bool HasValue => Value is not null; | ||
internal readonly record struct Result<TValue>(TValue? Value, Exception? Error) | ||
{ | ||
[MemberNotNullWhen(true, nameof(Value))] | ||
internal bool IsSucessfulWithValue => Value is not null && Error is null; | ||
|
||
public static implicit operator Result<TValue>(TValue value) => new(value, default!); | ||
public static implicit operator Result<TValue>(TValue value) => new(value, null); | ||
|
||
public static implicit operator Result<TValue>(Exception error) => new(default!, error); | ||
public static implicit operator Result<TValue>(Exception error) => new(default, error); | ||
} |