-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper impl Ord for Limit
#389
Conversation
Signed-off-by: Alex Snaps <[email protected]>
use std::collections::HashMap; | ||
|
||
#[test] | ||
fn properly_updates_existing_limits() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was "just" to reproduce the None.unwrap()
, thought I'd leave it in nonetheless
impl Ord for Limit
@@ -49,7 +49,7 @@ impl From<String> for Namespace { | |||
} | |||
} | |||
|
|||
#[derive(Eq, Debug, Clone, PartialOrd, Ord, Serialize, Deserialize)] | |||
#[derive(Eq, Debug, Clone, Serialize, Deserialize)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the default PartialOrd
and Ord
doing instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses all the fields in the struct to compare... so it did consider max_value
, but also id
and name
Signed-off-by: Alex Snaps <[email protected]>
impl Ord for Limit
was out of sync withEq
... So looking up counters would fail when navigating theBTreeMap
🤦My bad!