forked from rust-lang/glacier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue: rust-lang/rust#86800
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#![feature(min_type_alias_impl_trait)] | ||
use std::future::Future; | ||
|
||
struct Connection { | ||
} | ||
|
||
trait Transaction { | ||
} | ||
|
||
struct TestTransaction<'conn> { | ||
conn: &'conn Connection | ||
} | ||
|
||
impl<'conn> Transaction for TestTransaction<'conn> { | ||
} | ||
|
||
struct Context { | ||
} | ||
|
||
type TransactionResult<O> = Result<O, ()>; | ||
|
||
type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>; | ||
|
||
fn execute_transaction_fut<'f, F, O>(f: F) -> impl FnOnce(&mut dyn Transaction) -> TransactionFuture<O> | ||
where | ||
F: FnOnce(&mut dyn Transaction) -> TransactionFuture<O> + 'f | ||
{ | ||
f | ||
} | ||
|
||
impl Context { | ||
async fn do_transaction<O>( | ||
&self, f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<O> | ||
) -> TransactionResult<O> | ||
{ | ||
let mut conn = Connection {}; | ||
let mut transaction = TestTransaction { conn: &mut conn }; | ||
f(&mut transaction).await | ||
} | ||
} |