Skip to content

Commit

Permalink
clippy: canonical partial_cmp implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Aug 8, 2024
1 parent bb88c18 commit fcb2c3d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/descriptor/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ impl<Pk: MiniscriptKey, Ext: Extension> Eq for Tr<Pk, Ext> {}

impl<Pk: MiniscriptKey, Ext: Extension> PartialOrd for Tr<Pk, Ext> {
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
match self.internal_key.partial_cmp(&other.internal_key) {
Some(cmp::Ordering::Equal) => {}
ord => return ord,
}
self.tree.partial_cmp(&other.tree)
Some(self.cmp(other))
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/extensions/param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ impl CovExtArgs {

impl PartialOrd for CovExtArgs {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
// HACKY implementation, need Ord/PartialOrd to make it work with other components
// in the library
self.to_string().partial_cmp(&other.to_string())
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/policy/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Eq for OrdF64 {}
// to derive both or neither. Better to be explicit.
impl PartialOrd for OrdF64 {
fn partial_cmp(&self, other: &OrdF64) -> Option<cmp::Ordering> {
self.0.partial_cmp(&other.0)
Some(self.cmp(other))
}
}
impl Ord for OrdF64 {
Expand Down

0 comments on commit fcb2c3d

Please sign in to comment.