oni_comb_parser_rs/core/
committed_status.rs1#[derive(Debug, Clone, Copy, PartialOrd, PartialEq)]
4pub enum CommittedStatus {
5 Committed,
6 Uncommitted,
7}
8
9impl From<bool> for CommittedStatus {
10 fn from(value: bool) -> Self {
11 if value {
12 CommittedStatus::Committed
13 } else {
14 CommittedStatus::Uncommitted
15 }
16 }
17}
18
19impl CommittedStatus {
20 pub fn is_committed(&self) -> bool {
22 match self {
23 CommittedStatus::Committed => true,
24 CommittedStatus::Uncommitted => false,
25 }
26 }
27
28 pub fn is_uncommitted(&self) -> bool {
30 !self.is_committed()
31 }
32
33 pub fn or(&self, other: Self) -> Self {
37 match (self, other) {
38 (CommittedStatus::Committed, _) => CommittedStatus::Committed,
39 (_, CommittedStatus::Committed) => CommittedStatus::Committed,
40 _ => CommittedStatus::Uncommitted,
41 }
42 }
43}