-
-
Notifications
You must be signed in to change notification settings - Fork 521
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 #1161
Conversation
umm @billy1624 aren't we using the latest stable Rust? am I missing something here - is some bit of it still in unstable realm? |
GATs should stabilize today with rust 1.65.0 |
Well, I'm wrong again, 1.65.0 exits in a week
Il gio 27 ott 2022, 19:11 Chris Tsang ***@***.***> ha scritto:
… generic associated types are unstable
umm @billy1624 <https://github.com/billy1624> aren't we using the latest
stable Rust?
am I missing something here - it some bit of it still in unstable realm?
—
Reply to this email directly, view it on GitHub
<#1161 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABZXINORV7L4G2EG3IZACXTWFKZT5ANCNFSM6AAAAAARP2VTVU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Yeah I have been using it without the |
Tried again! Cool, I think the clippy error is unrelated to this PR and we should fix it on master @billy1624 Actually, I have no clue about Rust's tentative release dates. |
Yes, it's not from my PR
A new stable every 6 weeks https://www.whatrustisit.com/ |
One question, I think this does not break the API despite type changes, so justifiable as a minor release? Edit: actually we use |
Well, as far as I know, you released 0.10.0 as a release candidate, so this
change won't be a problem
Il dom 6 nov 2022, 05:57 Chris Tsang ***@***.***> ha scritto:
… One question, I think this does not break the API despite ABI change, so
justifiable as a minor release. Agree?
—
Reply to this email directly, view it on GitHub
<#1161 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABZXINKJZHYDCYIOZQ3T52LWG43DFANCNFSM6AAAAAARP2VTVU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I released 0.10.2 anyway |
Mentioning rust-lang/rust#96709 |
@nappa85 Would you mind sharing a snippet that bugs you before but is solved by this change? I am drafting the release blog post for this feature and I would like to illustrate it with an example. I imagine you've had a generic 'stream processor' function that accepts a generic |
It wasn't a real bug, more a lifetime problem, let me explain... I always ask for a generic connection C: ConnectionTrait and, when needed, also StreamTrait and/or TransactionTrait. This way my functions can be called on a normal connection or on a transaction, or anything else. With old code, when you need StreamTrait, you end up needing a lifetime, e.g. async fn do_something<'a, C>(conn: &'a C) -> Result<...>
where C: ConnectionTrait + StreamTrait<'a> {...} Most of the times it worked like a charm, but sometimes it won't compile telling you that the connection is still borrowed when it really isn't, but the problem is generated by connection reference and stream sharing the same lifetime. It was on situations like that: async fn complex_situation<C>(conn: &C) -> Result<...>
where C: ConnectionTrait + TransactionTrait
{
let txn = conn.begin().await?;
do_something(&txn).await?;
txn.commit().await?;// here we have the error, because it tells txn is still borrowed
} Unfortunately I don't have a MVP demonstrating the problem. With GAT, the same function loses the lifetime, e.g. async fn do_something<C>(conn: &C) -> Result<...>
where C: ConnectionTrait + StreamTrait {...} This is cleaner, and the problem is solved because now the stream has his own lifetime disconnected from connection reference. |
@tyt2y3 I think we need to upgrade minimum rust version after merge GAT... |
Clone of PR #1149, but on master branch