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

GAT nature of Strategy::Future #8

Open
fogti opened this issue Sep 20, 2023 · 1 comment
Open

GAT nature of Strategy::Future #8

fogti opened this issue Sep 20, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@fogti
Copy link
Member

fogti commented Sep 20, 2023

pub trait Strategy<'a> {
/// The context needed to poll the future.
type Context: ?Sized;
/// The future returned by the [`Strategy::wait`] method.
type Future: Future + 'a;
/// Poll the event listener until it is ready.
fn poll<T>(
&mut self,
event_listener: Pin<&mut EventListener<T>>,
context: &mut Self::Context,
) -> Poll<T>;
/// Wait for the event listener to become ready.
fn wait(&mut self, evl: Pin<&'a mut EventListener>) -> Self::Future;
}

We should probably keep in mind that as soon as we bump the minimum rust version to 1.65 or higher (GATs stabilization) we can probably use the following instead:

pub trait Strategy {
    /// The context needed to poll the future.
    type Context: ?Sized;

    /// The future returned by the [`Strategy::wait`] method.
    type Future<'a>: Future + 'a;

    /// Poll the event listener until it is ready.
    fn poll<T>(
        &mut self,
        event_listener: Pin<&mut EventListener<T>>,
        context: &mut Self::Context,
    ) -> Poll<T>;

    /// Wait for the event listener to become ready.
    fn wait<'a>(&mut self, evl: Pin<&'a mut EventListener>) -> Self::Future<'a>;
}
@fogti fogti added the enhancement New feature or request label Sep 20, 2023
@notgull
Copy link
Member

notgull commented Sep 22, 2023

Yes, this is a more stable implementation of GATs. Once Debian Stable updates again we will probably be able to use actual GATs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants