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

Better lifetime bounds for traits methods that return futures #56

Open
matko opened this issue Mar 31, 2021 · 1 comment
Open

Better lifetime bounds for traits methods that return futures #56

matko opened this issue Mar 31, 2021 · 1 comment

Comments

@matko
Copy link
Member

matko commented Mar 31, 2021

Many of the trait methods that return futures return a future with a static lifetime bound. This requires these futures to take ownership of any data in self they require through cloning. While we usually can do that, since many of the data structures we actually use are wrapped in an Arc, it is actually unnecessary. By specifying that the future we return has the same lifetime as the self reference, it should be possible to write implementations that don't need to take ownership.

Trait methods should be rewritten to have these better lifetimes.

@github-actions github-actions bot added the triage issue to be triage label Mar 31, 2021
@Cheukting Cheukting removed the triage issue to be triage label Apr 6, 2021
@matko
Copy link
Member Author

matko commented Apr 12, 2021

the async_trait macro does this for free and should just be used everywhere.

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

3 participants