Skip to content
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

Merged
merged 2 commits into from
Nov 21, 2024
Merged

Proper impl Ord for Limit #389

merged 2 commits into from
Nov 21, 2024

Conversation

alexsnaps
Copy link
Member

@alexsnaps alexsnaps commented Nov 21, 2024

impl Ord for Limit was out of sync with Eq... So looking up counters would fail when navigating the BTreeMap 🤦
My bad!

@alexsnaps alexsnaps linked an issue Nov 21, 2024 that may be closed by this pull request
@alexsnaps alexsnaps marked this pull request as ready for review November 21, 2024 14:45
use std::collections::HashMap;

#[test]
fn properly_updates_existing_limits() {
Copy link
Member Author

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

@alexsnaps alexsnaps changed the title Use the proper ref to update existing limits Proper impl Ord for Limit Nov 21, 2024
@@ -49,7 +49,7 @@ impl From<String> for Namespace {
}
}

#[derive(Eq, Debug, Clone, PartialOrd, Ord, Serialize, Deserialize)]
#[derive(Eq, Debug, Clone, Serialize, Deserialize)]
Copy link
Contributor

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?

Copy link
Member Author

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

@alexsnaps alexsnaps merged commit 282932e into main Nov 21, 2024
10 checks passed
@alexsnaps alexsnaps deleted the issue_388 branch November 21, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

RateLimitPolicy does not work after being modified
2 participants