From 9cb60f5f49099f7c62c262acedb0147e55f443ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kl=C3=A4hn?= <39526136+Septias@users.noreply.github.com> Date: Tue, 29 Oct 2024 22:49:44 +0100 Subject: [PATCH] refactor: directly use connectives (#6128) Just a small refactoring. Instead of rebinding res all the time just use `and` and `and_then`how they are inteded to be used. Improves code readability imo. --- src/sql.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/sql.rs b/src/sql.rs index 827626481..c25cb654b 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -154,29 +154,28 @@ impl Sql { // don't have main database passphrase at this point. // See for documentation. // Without resetting import may fail due to existing tables. - let res = res.and_then(|_| { + res.and_then(|_| { conn.set_db_config(DbConfig::SQLITE_DBCONFIG_RESET_DATABASE, true) .context("failed to set SQLITE_DBCONFIG_RESET_DATABASE") - }); - let res = res.and_then(|_| { + }) + .and_then(|_| { conn.execute("VACUUM", []) .context("failed to vacuum the database") - }); - let res = res.and( + }) + .and( conn.set_db_config(DbConfig::SQLITE_DBCONFIG_RESET_DATABASE, false) .context("failed to unset SQLITE_DBCONFIG_RESET_DATABASE"), - ); - let res = res.and_then(|_| { + ) + .and_then(|_| { conn.query_row("SELECT sqlcipher_export('main', 'backup')", [], |_row| { Ok(()) }) .context("failed to import from attached backup database") - }); - let res = res.and( + }) + .and( conn.execute("DETACH DATABASE backup", []) .context("failed to detach backup database"), - ); - res?; + )?; Ok(()) }) .await