Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ops): op2 support for Result<impl Future<...>> #54

Merged
merged 4 commits into from
Jul 19, 2023

Conversation

mmastrac
Copy link
Contributor

@mmastrac mmastrac commented Jul 19, 2023

Supports Result<impl Future<...>>-style async ops like so:

  #[op2(async, core)]
  pub fn op_async_result_impl(
    mode: u8,
  ) -> Result<impl Future<Output = Result<(), Error>>, Error> {
    if mode == 0 {
      return Err(generic_error("early exit"));
    }
    return Ok(async move {
      if mode == 1 {
        return Err(generic_error("early async exit"));
      }
      tokio::time::sleep(Duration::from_millis(500)).await;
      if mode == 2 {
        return Err(generic_error("late async exit"));
      }
      return Ok(());
    });
  }

@mmastrac mmastrac mentioned this pull request Jul 19, 2023
18 tasks
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, provided the tests pass once lint error is fixed

@mmastrac mmastrac enabled auto-merge (squash) July 19, 2023 17:14
@mmastrac mmastrac merged commit 8f0bd98 into denoland:main Jul 19, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants