Skip to content

Pin-projecting in-line tuples #349

Open
@yoshuawuyts

Description

@yoshuawuyts

The following currently works:

use pin_project::pin_project;
use core::future::Future;

#[pin_project]
struct Pinned<A: Future, B: Future>(#[pin] A, #[pin] B);

But this doesn't:

use pin_project::pin_project;
use core::future::Future;

#[pin_project]
struct Pinned<A: Future, B: Future> {
    futures: (#[pin] A, #[pin] B),
}

So instead we now have to do:

use pin_project::pin_project;
use core::future::Future;

#[pin_project]
struct Futures<A: Future, B: Future> (#[pin] A, #[pin] B);

#[pin_project]
struct Pinned<A: Future, B: Future> {
    futures: Futures<A, B>,
}

We ran into some issues with this in yoshuawuyts/futures-concurrency#74. I'm not sure how feasible this would be to provide, but being able to pin-project into individual enum fields would save us from having to generate an intermediate struct. So I figured I'd raise it here; hope that's alright!

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: A new feature or an improvement for an existing one

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions