-
-
Notifications
You must be signed in to change notification settings - Fork 522
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
use GAT to elide StreamTrait lifetime #1149
Conversation
Welcome back! Yes I think GAT can be used to replace the use of Awesome! Let me know the progress or problems. |
How do you think to use GAT to replace async_trait? Because, as far as I know, while we don't have TAIT we can't have Anyway, until now, all the problems I've found wasn't sea-orm's related, I'll keep you updated |
I think I learnt this technique here: https://www.sobyte.net/post/2022-04/rust-gat-async-trait/
No concrete plan for now |
Yes, this uses both GATs and TAITs
but when you impl the trait you still need to use a concrete type, the only difference is that it can have a lifetime that isn't global to the trait himself |
Umm... I think the original concern is that |
Yes, what I'm trying to say is that to replace async_trait you need both GAT and TAIT, like in your article
or else you need to create a concrete future type for every return, like tokio does internally |
Ah sad I forgot TAIT is still unstable. Some day, then. |
My tests are all green, I'll open another PR for master branch |
Thinking about the breaking change, maybe you'll prefer merging this only on 0.10.0 to not introduce breaking changes on 0.9.x |
I think we can close this? |
Since this requires newer Rust version, I don't think we can backport this |
Hello guys, I'm back!
Thursday Rust 1.65.0 will be stabilized, and with it GATs will land on stable.
I've seen only this morning you've release a release candidate for 0.10.0, but this work is portable to the new version for sure.
Long story short, using GATs we can remove the lifetime from StreamTrait and move it internally.
To be honest, that lifetime has given me more than one headache, I think this is a big usability improvement.
It's still a work in progress, I'm still testing, I've already seen some corner cases and I'll work on it tomorrow, but I wanted to share with you this improvement so you can start thinking about landing an improvement that needs next stable compiler to work
Best regards
edit: I wrote TAIT instead of GAT, I need some rest...