2022-02-17 13:55:58 +00:00
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ edition:2021
|
2022-02-17 13:55:58 +00:00
|
|
|
|
|
|
|
|
use std::future::Future;
|
|
|
|
|
|
2024-07-26 10:04:02 +00:00
|
|
|
struct Connection {}
|
2022-02-17 13:55:58 +00:00
|
|
|
|
2024-07-26 10:04:02 +00:00
|
|
|
trait Transaction {}
|
2022-02-17 13:55:58 +00:00
|
|
|
|
|
|
|
|
struct TestTransaction<'conn> {
|
2024-07-26 10:04:02 +00:00
|
|
|
conn: &'conn Connection,
|
2022-02-17 13:55:58 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-26 10:04:02 +00:00
|
|
|
impl<'conn> Transaction for TestTransaction<'conn> {}
|
2022-02-17 13:55:58 +00:00
|
|
|
|
2024-07-26 10:04:02 +00:00
|
|
|
struct Context {}
|
2022-02-17 13:55:58 +00:00
|
|
|
|
|
|
|
|
type TransactionResult<O> = Result<O, ()>;
|
|
|
|
|
|
|
|
|
|
type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
|
|
|
|
|
|
2024-07-26 10:04:02 +00:00
|
|
|
#[define_opaque(TransactionFuture)]
|
2022-02-17 13:55:58 +00:00
|
|
|
fn execute_transaction_fut<'f, F, O>(
|
2024-06-10 16:17:38 +00:00
|
|
|
//~^ ERROR: item does not constrain
|
2022-02-17 13:55:58 +00:00
|
|
|
f: F,
|
2022-03-11 11:58:59 +01:00
|
|
|
) -> impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>
|
2022-02-17 13:55:58 +00:00
|
|
|
where
|
2024-07-26 10:04:02 +00:00
|
|
|
F: FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> + 'f,
|
2022-02-17 13:55:58 +00:00
|
|
|
{
|
|
|
|
|
f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Context {
|
2024-07-26 10:04:02 +00:00
|
|
|
#[define_opaque(TransactionFuture)]
|
2022-02-17 13:55:58 +00:00
|
|
|
async fn do_transaction<O>(
|
2024-06-10 16:17:38 +00:00
|
|
|
//~^ ERROR: item does not constrain
|
2024-07-26 10:04:02 +00:00
|
|
|
&self,
|
|
|
|
|
f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>,
|
|
|
|
|
) -> TransactionResult<O> {
|
2022-02-17 13:55:58 +00:00
|
|
|
let mut conn = Connection {};
|
|
|
|
|
let mut transaction = TestTransaction { conn: &mut conn };
|
|
|
|
|
f(&mut transaction).await
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {}
|