From adb96e72b9a77c860cde2678a4aa5595c0b65969 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 15 Feb 2020 16:28:02 +0300 Subject: [PATCH] Pass mutable Connection reference to with_conn callback This makes it possible to call .transaction() method on connection. --- src/sql.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sql.rs b/src/sql.rs index 9a3ab31a8..be0641228 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -115,11 +115,11 @@ impl Sql { fn with_conn(&self, g: G) -> Result where - G: FnOnce(&Connection) -> Result, + G: FnOnce(&mut Connection) -> Result, { let res = match &*self.pool.read().unwrap() { Some(pool) => { - let conn = pool.get()?; + let mut conn = pool.get()?; // Only one process can make changes to the database at one time. // busy_timeout defines, that if a second process wants write access, @@ -130,7 +130,7 @@ impl Sql { // (without a busy_timeout, sqlite3_step() would return SQLITE_BUSY _at once_) conn.busy_timeout(Duration::from_secs(10))?; - g(&conn) + g(&mut conn) } None => Err(Error::SqlNoConnection), };