moves extensions

This commit is contained in:
Robin Ehlert
2025-07-26 16:27:52 +02:00
parent 94ad6e57d7
commit 84be8314bf
3 changed files with 3 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
namespace Rehlert.RoP;
public static class FallbackExtensions
{
public static TIn FallbackWith<TIn, TErr>(this Result<TIn, TErr> value, TIn defaultValue)
{
var result = value.Match(
ok => ok.Value,
_ => defaultValue
);
return result;
}
public static async Task<TIn> FallbackWith<TIn, TErr>(
this Task<Result<TIn, TErr>> value,
TIn defaultValue
)
{
var valRes = await value;
var result = valRes.Match(
ok => ok.Value,
_ => defaultValue
);
return result;
}
}