Lifetime error with self-referential type (redb::WriteTransaction)

(I only skimmed most of this thread and then looked at the last playground link, but:)

If you change the declaration order, it compiles.

+    let use_transaction;
     let db_wrapper = DbWrapper(Database());
     let mut cache_table = CacheTable(None);
-    let use_transaction = db_wrapper.begin_write();
+    use_transaction = db_wrapper.begin_write();
     use_transaction.compute_some_thing(&mut cache_table);
2 Likes