diff options
Diffstat (limited to 'src/db/model/state.rs')
| -rw-r--r-- | src/db/model/state.rs | 22 |
1 files changed, 7 insertions, 15 deletions
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 { |
