summaryrefslogtreecommitdiffstats
path: root/src/db/world.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
committeraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
commit3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (patch)
tree7cc7169181b4bdd73fd8817f8c1d7cce6e6998a8 /src/db/world.rs
parent9dc9087d89891c6e5ef7e5dc084dd13c8611843e (diff)
downloadaur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.tar.gz
aur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.zip
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.
Diffstat (limited to 'src/db/world.rs')
-rw-r--r--src/db/world.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/db/world.rs b/src/db/world.rs
index 73e327f..19a28f1 100644
--- a/src/db/world.rs
+++ b/src/db/world.rs
@@ -1,6 +1,6 @@
use rusqlite::params;
-use crate::db::*;
+use crate::db::{json_or, Db, WorldMember, Writer};
use crate::error::Result;
use crate::time;
@@ -19,8 +19,7 @@ pub fn put_world_snapshot(writer: &Writer, members: &[WorldMember]) -> Result<i6
ON CONFLICT(hash) DO NOTHING",
params![hash, json, at],
)?;
- tx.query_row("SELECT id FROM world_snapshot WHERE hash=?1", params![hash], |r| r.get(0))
- .map_err(Into::into)
+ tx.query_row("SELECT id FROM world_snapshot WHERE hash=?1", params![hash], |r| r.get(0)).map_err(Into::into)
})
}
@@ -31,12 +30,8 @@ pub fn put_world_snapshot(writer: &Writer, members: &[WorldMember]) -> Result<i6
#[cfg(feature = "test-support")]
pub fn world_members(db: &Db, id: i64) -> Result<Vec<WorldMember>> {
db.read(|c| {
- let s: String = c.query_row(
- "SELECT members_json FROM world_snapshot WHERE id=?1",
- params![id],
- |r| r.get(0),
- )?;
+ let s: String =
+ c.query_row("SELECT members_json FROM world_snapshot WHERE id=?1", params![id], |r| r.get(0))?;
Ok(json_or(&s, Vec::new()))
})
}
-