From 7031176fd25243caf14271410974d9a4b97ec201 Mon Sep 17 00:00:00 2001 From: Andrew Wells Date: Thu, 5 Oct 2023 17:28:59 +0000 Subject: [PATCH] use self.cmp in partial_cmp if type implements Ord and PartialOrd --- cedar-policy-core/src/ast/extension.rs | 2 +- cedar-policy-core/src/ast/value.rs | 4 +--- cedar-policy-core/src/authorizer.rs | 12 +++--------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/cedar-policy-core/src/ast/extension.rs b/cedar-policy-core/src/ast/extension.rs index 935a8abea..192c8be98 100644 --- a/cedar-policy-core/src/ast/extension.rs +++ b/cedar-policy-core/src/ast/extension.rs @@ -403,7 +403,7 @@ impl Eq for ExtensionValueWithArgs {} impl PartialOrd for ExtensionValueWithArgs { fn partial_cmp(&self, other: &Self) -> Option { - self.value.partial_cmp(&other.value) + Some(self.cmp(other)) } } diff --git a/cedar-policy-core/src/ast/value.rs b/cedar-policy-core/src/ast/value.rs index c0e767a27..62a50cc1e 100644 --- a/cedar-policy-core/src/ast/value.rs +++ b/cedar-policy-core/src/ast/value.rs @@ -296,9 +296,7 @@ impl Eq for Set {} // HashSet doesn't implement PartialOrd impl PartialOrd for Set { fn partial_cmp(&self, other: &Set) -> Option { - self.authoritative - .as_ref() - .partial_cmp(other.authoritative.as_ref()) + Some(self.cmp(other)) } } diff --git a/cedar-policy-core/src/authorizer.rs b/cedar-policy-core/src/authorizer.rs index ebaa82379..c60b02873 100644 --- a/cedar-policy-core/src/authorizer.rs +++ b/cedar-policy-core/src/authorizer.rs @@ -113,16 +113,12 @@ impl Authorizer { match self.error_handling { ErrorHandling::Deny => Response::new( Decision::Deny, - idset - .chain(partial.diagnostics.reason) - .collect(), + idset.chain(partial.diagnostics.reason).collect(), errors, ), ErrorHandling::Forbid => Response::new( Decision::Deny, - idset - .chain(partial.diagnostics.reason) - .collect(), + idset.chain(partial.diagnostics.reason).collect(), errors, ), ErrorHandling::Skip => { @@ -148,9 +144,7 @@ impl Authorizer { } else { Response::new( Decision::Deny, - idset - .chain(partial.diagnostics.reason) - .collect(), + idset.chain(partial.diagnostics.reason).collect(), errors, ) }