Skip to content

Commit

Permalink
use self.cmp in partial_cmp if type implements Ord and PartialOrd
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmwells-amazon committed Oct 5, 2023
1 parent c004d17 commit 7031176
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cedar-policy-core/src/ast/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ impl Eq for ExtensionValueWithArgs {}

impl PartialOrd for ExtensionValueWithArgs {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.value.partial_cmp(&other.value)
Some(self.cmp(other))
}
}

Expand Down
4 changes: 1 addition & 3 deletions cedar-policy-core/src/ast/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ impl Eq for Set {}
// HashSet doesn't implement PartialOrd
impl PartialOrd<Set> for Set {
fn partial_cmp(&self, other: &Set) -> Option<std::cmp::Ordering> {
self.authoritative
.as_ref()
.partial_cmp(other.authoritative.as_ref())
Some(self.cmp(other))
}
}

Expand Down
12 changes: 3 additions & 9 deletions cedar-policy-core/src/authorizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -148,9 +144,7 @@ impl Authorizer {
} else {
Response::new(
Decision::Deny,
idset
.chain(partial.diagnostics.reason)
.collect(),
idset.chain(partial.diagnostics.reason).collect(),
errors,
)
}
Expand Down

0 comments on commit 7031176

Please sign in to comment.