Skip to content

Conversation

@addap
Copy link
Contributor

@addap addap commented Jul 9, 2025

I realized that the easiest way is to just rely on the derived implementations of the Eq and Ord traits.
To still get alphabetical sorting we must put the name field before the id field.
Added two tests that fail on master and pass now.

addap added 2 commits July 9, 2025 23:14
The previous handwritten implementations were not consistent with each
other as they allowed values a & b where a == b but a < b.
Fixes teloxide#35
@hirrolot hirrolot self-requested a review July 9, 2025 21:18
Copy link
Member

@hirrolot hirrolot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM. Would you also add a CHANGELOG.md entry explaining your changes? Thanks!

addap added 4 commits July 11, 2025 00:54
The current implementation only zips the two key iterators together. So if
one of them is a subset of the other it only checks the keys in the
subset for equality. In the simplest case, the empty dependency map is
equal to every other dependency map.
Analogous to how equality is defined for BTreeMap, but only looking at keys.
@hirrolot hirrolot self-requested a review July 10, 2025 23:05
Copy link
Member

@hirrolot hirrolot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for figuring this out!

@hirrolot hirrolot merged commit 105af27 into teloxide:master Jul 10, 2025
1 check passed
@addap
Copy link
Contributor Author

addap commented Jul 10, 2025

Okay, I just added an entry to the Changelog.

Also I was looking at other PartialEq implementations in the project and noticed that the one for DependencyMap might be wrong. When zipping together the two lists, if one of them is shorter than the other, the zip ends after the shorter list does not have any more items. As a consequence, only keys in the shorter list are checked for equality and therefore the empty dependency map is equal to every other. I assume this is wrong so I added a test & fix for that, too.

@hirrolot
Copy link
Member

hirrolot commented Jul 11, 2025

I've released v0.5.1 with your fix.

@addap addap deleted the fix-type-eq-ord branch January 24, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants