BREAKING CHANGE: feat: use record struct for Result

This commit is contained in:
Kyle Ratti 2024-05-03 17:06:55 -04:00
parent c5d2de1f4a
commit 1be0893d19
No known key found for this signature in database
GPG Key ID: 4D429B6287C68DD9

View File

@ -2,7 +2,7 @@
namespace FruityFoundation.Base.Structures; namespace FruityFoundation.Base.Structures;
public readonly struct Result<TSuccess, TFailure> public readonly record struct Result<TSuccess, TFailure>
{ {
private readonly Maybe<TSuccess> _successVal; private readonly Maybe<TSuccess> _successVal;
private readonly Maybe<TFailure> _failureVal; private readonly Maybe<TFailure> _failureVal;
@ -49,5 +49,7 @@ public readonly struct Result<TSuccess, TFailure>
} }
public T Merge<T>(Func<TSuccess, T> onSuccess, Func<TFailure, T> onFailure) => public T Merge<T>(Func<TSuccess, T> onSuccess, Func<TFailure, T> onFailure) =>
IsSuccess ? onSuccess(_successVal.Value) : onFailure(_failureVal.Value); IsSuccess
? onSuccess(_successVal.Value)
: onFailure(_failureVal.Value);
} }