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

Update traits to use AFITs / associated impl Future #162

Open
yoshuawuyts opened this issue Jan 6, 2024 · 1 comment
Open

Update traits to use AFITs / associated impl Future #162

yoshuawuyts opened this issue Jan 6, 2024 · 1 comment

Comments

@yoshuawuyts
Copy link
Owner

Now that async traits are stable, we may want to consider filing a patch to use them. Not sure yet if we should merge it, but we should at least try it out.

For Join it should not be an AFIT, but instead use an impl Future as its associated type.

@yoshuawuyts
Copy link
Owner Author

yoshuawuyts commented Jan 6, 2024

// most traits like this
impl<A: Future, B: Future> Race for (A, B) {
    async fn race(self) -> (A::Output, B::Output) ;
}

// but `Join` should be like this...
impl<A: Future, B: Future> Join for (A, B) {
    type Future = impl Future<Output = (A::Output, B::Output)>;
    fn join(self) -> Self::Future;
}

// ... so that we can implement it in std like this
impl<A: Future, B: Future> IntoFuture for (A, B) {
    type IntoFuture = impl Future<Output = (A::Output, B::Output)>;
    fn into_future(self) -> Self:: IntoFuture;
}

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

No branches or pull requests

1 participant