From 3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 Mon Sep 17 00:00:00 2001 From: aur-build Date: Sun, 22 Nov 2026 10:36:24 +0000 Subject: rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off rustfmt.toml fixes the shape the tree is written in (120 columns, small items kept on one line) and one canonical pass makes it the truth. [lints.clippy] names the idiom lints worth enforcing and leaves out the two that would add doc-comment boilerplate rather than remove it. The tree pays them off here: write!/writeln! instead of push_str(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&self` on a Copy state and no `self` nobody reads. ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and value are now emitted by the same call instead of three. --- src/db/publish_writes.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/db/publish_writes.rs') diff --git a/src/db/publish_writes.rs b/src/db/publish_writes.rs index e5ce73f..11679cf 100644 --- a/src/db/publish_writes.rs +++ b/src/db/publish_writes.rs @@ -1,29 +1,24 @@ use rusqlite::{params, params_from_iter, OptionalExtension}; -use crate::db::*; +use crate::db::Db; use crate::error::Result; // ------------------------------------------------------------ publish writes -- pub fn artifact_path(db: &Db, id: i64) -> Result> { db.read(|c| { - Ok(c.query_row("SELECT path FROM artifact WHERE id=?1", params![id], |r| r.get::<_, String>(0)) - .optional()?) + Ok(c.query_row("SELECT path FROM artifact WHERE id=?1", params![id], |r| r.get::<_, String>(0)).optional()?) }) } fn artifact_id_by_digest_in(tx: &rusqlite::Transaction<'_>, digest: &str) -> Result> { - Ok(tx - .query_row("SELECT id FROM artifact WHERE digest=?1", params![digest], |r| r.get::<_, i64>(0)) - .optional()?) + Ok(tx.query_row("SELECT id FROM artifact WHERE digest=?1", params![digest], |r| r.get::<_, i64>(0)).optional()?) } pub fn accepted_pointer_in(tx: &rusqlite::Transaction<'_>, pkgbase_id: i64) -> Result> { - tx.query_row( - "SELECT current_accepted_release_id FROM pkgbase WHERE id=?1", - params![pkgbase_id], - |r| r.get::<_, Option>(0), - ) + tx.query_row("SELECT current_accepted_release_id FROM pkgbase WHERE id=?1", params![pkgbase_id], |r| { + r.get::<_, Option>(0) + }) .optional() .map(Option::flatten) .map_err(Into::into) @@ -54,10 +49,7 @@ pub fn remove_index_packages_in(tx: &rusqlite::Transaction<'_>, names: &[String] } pub fn remove_package_by_name_in(tx: &rusqlite::Transaction<'_>, repo_id: i64, name: &str) -> Result<()> { - tx.execute( - "UPDATE package SET state='removed' WHERE repo_id=?1 AND name=?2", - params![repo_id, name], - )?; + tx.execute("UPDATE package SET state='removed' WHERE repo_id=?1 AND name=?2", params![repo_id, name])?; Ok(()) } @@ -118,4 +110,3 @@ pub fn insert_package_in( )?; Ok(()) } - -- cgit v1.2.3