Skip to content

await builders directly #22

@danieleades

Description

@danieleades

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestupstreamRequires an update to an upstream dependency

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions