From 74ad3bf887ddd8ace3b759ccd4d5971589ab8610 Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Mon, 20 Apr 2026 09:28:46 +0000 Subject: [PATCH] Replace the existential lifetime in sqlite adapter with a static one (#1407) Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1407 Reviewed-by: Alex --- src/db/sqlite_adapter.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index b640e273..cb778eb5 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -426,15 +426,20 @@ impl<'a> ITx for SqliteTx<'a> { // complicated, they must hold the Statement and Row objects // therefore quite some unsafe code (it is a self-referential struct) -struct DbValueIterator<'a> { +struct DbValueIterator { db: Connection, - stmt: Option>, - iter: Option>, + // These two are not really static (they are actually self referential :o) + stmt: Option>, + iter: Option>, _pin: PhantomPinned, } -impl<'a> DbValueIterator<'a> { - fn make(db: Connection, sql: &str, args: P) -> Result> { +impl DbValueIterator { + fn make<'res, P: rusqlite::Params>( + db: Connection, + sql: &str, + args: P, + ) -> Result> { let res = DbValueIterator { db, stmt: None, @@ -468,7 +473,7 @@ impl<'a> DbValueIterator<'a> { } } -impl<'a> Drop for DbValueIterator<'a> { +impl Drop for DbValueIterator { fn drop(&mut self) { trace!("drop iter"); drop(self.iter.take()); @@ -476,9 +481,9 @@ impl<'a> Drop for DbValueIterator<'a> { } } -struct DbValueIteratorPin<'a>(Pin>>); +struct DbValueIteratorPin(Pin>); -impl<'a> Iterator for DbValueIteratorPin<'a> { +impl Iterator for DbValueIteratorPin { type Item = Result<(Value, Value)>; fn next(&mut self) -> Option {