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/model/state.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'src/db/model/state.rs') diff --git a/src/db/model/state.rs b/src/db/model/state.rs index 18860ff..4057652 100644 --- a/src/db/model/state.rs +++ b/src/db/model/state.rs @@ -1,6 +1,5 @@ use serde::{Deserialize, Serialize}; - use crate::db::model::build_state::{BuildState, StepState}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] @@ -40,9 +39,9 @@ impl CandidateState { *self == CandidateState::PendingReview } - fn can_transition(&self, to: CandidateState) -> bool { - use CandidateState::*; - if *self == to { + fn can_transition(self, to: CandidateState) -> bool { + use CandidateState::{Approved, Blocked, PendingReview, Rejected, Superseded}; + if self == to { return true; } match self { @@ -54,11 +53,7 @@ impl CandidateState { } pub(crate) fn predecessors(to: CandidateState) -> Vec<&'static str> { - CandidateState::ALL - .iter() - .filter(|from| from.can_transition(to)) - .map(|from| from.as_str()) - .collect() + CandidateState::ALL.iter().filter(|from| from.can_transition(to)).map(CandidateState::as_str).collect() } } @@ -78,7 +73,7 @@ pub mod candidate_kind { /// only way to reach it, and the alias is what carries the /// feature-conditional visibility. mod release_state { - use super::*; + use super::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] @@ -101,11 +96,8 @@ pub use release_state::ReleaseState; pub(crate) use release_state::ReleaseState; impl ReleaseState { - const ALL: &'static [ReleaseState] = &[ - ReleaseState::Published, - ReleaseState::Withdrawn, - ReleaseState::FailedUnbuilt, - ]; + const ALL: &'static [ReleaseState] = + &[ReleaseState::Published, ReleaseState::Withdrawn, ReleaseState::FailedUnbuilt]; pub fn as_str(&self) -> &'static str { match self { -- cgit v1.2.3