Open
Description
I haven't seen it discussed anywhere, but could sqlx benefit from AFIT as-is?
This was recently released with 1.75 (2023-12-28). As I understand it, it would mean that some of the traits that look pretty messy:
pub trait Executor<'c>: Send + Debug + Sized {
type Database: Database;
fn fetch_optional<'e, 'q, E>(
self,
query: E
) -> Pin<Box<dyn Future<Output = Result<Option<<Self::Database as Database>::Row>, Error>> + Send + 'e>>
where 'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>;
// ...
}
Can now be written with a more understandable syntax, which also drops the Box<dyn ...>
indirection:
pub trait Executor<'c>: Send + Debug + Sized {
type Database: Database;
async fn fetch_optional<'e, 'q, E>(
self,
query: E
) -> Result<Option<<Self::Database as Database>::Row>, Error>
where 'q: 'e,
'c: 'e,
E: 'q + Execute<'q, Self::Database>;
// ...
}
The blog post here has more information https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html. It seems like the limitations could make things less usable, but perhaps still beneficial?
Obviously putting this to use would be a MSRV break so it won't be usable anytime soon, but I am just curious if this has been looked at at all.
Thanks!