Skip to content

Commit

Permalink
simplified and improved
Browse files Browse the repository at this point in the history
  • Loading branch information
waylaa committed Dec 8, 2023
1 parent ee138fd commit 5735d29
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions OsuCollectionDownloader/Objects/Result.cs
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);
}

0 comments on commit 5735d29

Please sign in to comment.