using System;
using System.Threading.Tasks;

namespace CSharpFunctionalExtensions
{
    public static partial class ResultExtensions
    
{
        public static async Task<Result<T>> Try<T>(this Result<T> result, Func<Task<T>> func)
        {
            if (result.IsFailure)
            {
                return result;
            }

            return await func();
        }