diff --git a/src/Monads/Maybe/Maybe.cs b/src/Monads/Maybe/Maybe.cs index c3fd0ea..5d31dec 100644 --- a/src/Monads/Maybe/Maybe.cs +++ b/src/Monads/Maybe/Maybe.cs @@ -93,8 +93,7 @@ public Maybe(TValue? value) public Maybe Map(Func map) where TNewValue : class => Value is not null ? new Maybe(map(Value)) : Maybe.None; - public Result MapToResult() => - Value is not null ? Result.Success(Value) : Result.Failure(MaybeNoneError.Default); + /// public async Task> Map(Func> map) where TNewValue : class diff --git a/src/Monads/Maybe/MaybeAsyncExtensions.cs b/src/Monads/Maybe/MaybeAsyncExtensions.cs index 96686eb..0280cf5 100644 --- a/src/Monads/Maybe/MaybeAsyncExtensions.cs +++ b/src/Monads/Maybe/MaybeAsyncExtensions.cs @@ -191,7 +191,16 @@ public static Task Satisfy(this Task> maybe, Func maybe.Match(predicate, false); - /// + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static async Task> ToResult(this Task> maybeTask) where TValue : class + { + var maybe = await maybeTask; + return maybe.MapToResult(); + } + + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static async Task> ToResult(this Task> maybeTask, Func errorFunc) where TValue : class { @@ -199,7 +208,8 @@ public static async Task> ToResult(this Task + + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static async Task> ToResult(this Task> maybeTask, Func> errorFunc) where TValue : class { diff --git a/src/Monads/Maybe/MaybeExtensions.cs b/src/Monads/Maybe/MaybeExtensions.cs index 47025f0..3c16a84 100644 --- a/src/Monads/Maybe/MaybeExtensions.cs +++ b/src/Monads/Maybe/MaybeExtensions.cs @@ -228,7 +228,6 @@ Func> value /// /// Convert a to a with a default error in case of None. /// - /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Result MapToResult(this Maybe maybe) where TValue : class