Skip to main content

propaga_core/
status.rs

1/// Result of a single propagator invocation or propagation round.
2#[derive(Clone, Copy, Debug, PartialEq, Eq)]
3pub enum PropagationStatus {
4    /// Propagation ran but no domain changed.
5    OkNoChange,
6    /// At least one domain was tightened.
7    OkChanged,
8    /// A domain became empty, indicating a conflict.
9    Failure,
10}
11
12impl PropagationStatus {
13    /// Returns `true` when propagation detected a conflict.
14    #[must_use]
15    pub const fn is_failure(self) -> bool {
16        matches!(self, Self::Failure)
17    }
18
19    /// Returns `true` when propagation changed at least one domain.
20    #[must_use]
21    pub const fn changed(self) -> bool {
22        matches!(self, Self::OkChanged)
23    }
24
25    /// Combines two statuses, preferring failure, then change.
26    #[must_use]
27    pub const fn merge(self, other: Self) -> Self {
28        match (self, other) {
29            (Self::Failure, _) | (_, Self::Failure) => Self::Failure,
30            (Self::OkChanged, _) | (_, Self::OkChanged) => Self::OkChanged,
31            _ => Self::OkNoChange,
32        }
33    }
34}