Commit 71caf81 1 parent 4bab5fa commit 71caf81 Copy full SHA for 71caf81
File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( min_type_alias_impl_trait) ]
2
+ use std:: future:: Future ;
3
+
4
+ struct Connection {
5
+ }
6
+
7
+ trait Transaction {
8
+ }
9
+
10
+ struct TestTransaction < ' conn > {
11
+ conn : & ' conn Connection
12
+ }
13
+
14
+ impl < ' conn > Transaction for TestTransaction < ' conn > {
15
+ }
16
+
17
+ struct Context {
18
+ }
19
+
20
+ type TransactionResult < O > = Result < O , ( ) > ;
21
+
22
+ type TransactionFuture < ' __ , O > = impl ' __ + Future < Output = TransactionResult < O > > ;
23
+
24
+ fn execute_transaction_fut < ' f , F , O > ( f : F ) -> impl FnOnce ( & mut dyn Transaction ) -> TransactionFuture < O >
25
+ where
26
+ F : FnOnce ( & mut dyn Transaction ) -> TransactionFuture < O > + ' f
27
+ {
28
+ f
29
+ }
30
+
31
+ impl Context {
32
+ async fn do_transaction < O > (
33
+ & self , f : impl FnOnce ( & mut dyn Transaction ) -> TransactionFuture < O >
34
+ ) -> TransactionResult < O >
35
+ {
36
+ let mut conn = Connection { } ;
37
+ let mut transaction = TestTransaction { conn : & mut conn } ;
38
+ f ( & mut transaction) . await
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments