implementing PartialOrd for Decision instead of defining custom is_stricter_than func

This commit is contained in:
kevin zhao
2025-11-10 17:20:51 -08:00
parent 270abdc0c4
commit 2952c14719
2 changed files with 2 additions and 17 deletions

View File

@@ -4,7 +4,7 @@ use serde::Serialize;
use crate::error::Error;
use crate::error::Result;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Decision {
Allow,
@@ -21,13 +21,4 @@ impl Decision {
other => Err(Error::InvalidDecision(other.to_string())),
}
}
/// Returns true if `self` is stricter (less permissive) than `other`.
pub fn is_stricter_than(self, other: Self) -> bool {
matches!(
(self, other),
(Decision::Forbidden, Decision::Prompt | Decision::Allow)
| (Decision::Prompt, Decision::Allow)
)
}
}