Skip to content

Result.Try with async lambda returning Result<T> #234

Description

@LaXiS96

Hello,
I am trying to use Result.Try with an async lambda based on the non-async example in the README, somewhat like this:

Result<Guid> result = await Result.Try(async Task<Result<Guid>> () => {
    await Task.Delay(100);
    return Result.Ok(new Guid());
});

but Result.Try returns a Result<Result<Guid>> which is not what I expected.

Could this case be handled by adding an overload like this?

Task<Result<T>> Result.Try<T>(Func<Task<Result<T>>> action, ...)

Or is there a recommended way to handle this differently?

Thank you

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions