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

await builders directly #22

Open
danieleades opened this issue Mar 7, 2020 · 0 comments
Open

await builders directly #22

danieleades opened this issue Mar 7, 2020 · 0 comments
Labels
enhancement New feature or request upstream Requires an update to an upstream dependency

Comments

@danieleades
Copy link
Contributor

danieleades commented Mar 7, 2020

It would be nice to await builders directly.

There's a nice explanation of this pattern here - https://blog.yoshuawuyts.com/async-finalizers/

it will allow us to rewrite this-

let index = Index::init(root, download)
    .build()
    .await?;

like this-

let index = Index::init(root, download)
    .await?;

There are two options for doing this

  1. implement Future for the builders. This isn't too hard, but it's not that clean, and makes the code look a little unapproachable.
  2. implement IntoFuture for the builders. This relies on an unmerged nightly feature, and has been stuck in limbo for a while - Re-land "add IntoFuture trait and support for await" rust-lang/rust#68811
@danieleades danieleades added enhancement New feature or request upstream Requires an update to an upstream dependency labels Mar 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upstream Requires an update to an upstream dependency
Projects
None yet
Development

No branches or pull requests

1 participant