Skip to content

Commit

Permalink
Use cmp of Self in implementaions of partial_cmp (bevyengine#8559)
Browse files Browse the repository at this point in the history
# Objective

Ensure future consistency between the two compare functions for all
types with manual `Ord` and `PartialOrd` implementations.

## Solution

Use `Self::cpm` in the implementation of `partial_cpm` for types
`Handle` and `Name`.
  • Loading branch information
konsti219 committed May 6, 2023
1 parent d319910 commit 1530f63
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl<T: Asset> Eq for Handle<T> {}

impl<T: Asset> PartialOrd for Handle<T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.id.cmp(&other.id))
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core/src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl Eq for Name {}

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

Expand Down

0 comments on commit 1530f63

Please sign in to comment.