Skip to content

Remove comparable constraint from DedupBy#33

Merged
orsinium merged 1 commit intolife4:masterfrom
dwurf:dedupby-for-non-comparable
Apr 23, 2024
Merged

Remove comparable constraint from DedupBy#33
orsinium merged 1 commit intolife4:masterfrom
dwurf:dedupby-for-non-comparable

Conversation

@dwurf
Copy link
Copy Markdown
Contributor

@dwurf dwurf commented Apr 23, 2024

I couldn't see any reason for DedupBy to require elements in the slice to be comparable, since the comparison is done by the function.

This change relaxes the comparable constraint and adds a test case to prove that non-comparable types can be deduped.

The test case is a bit silly, but it's easy to imagine wanting to dedup structs with slices in them and needing this (which is
what I needed).

I couldn't see any reason for DedupBy to require elements in the slice to be comparable,
since the comparison is done by the function.

This change relaxes the `comparable` constraint and adds a test case to prove that
non-comparable types can be deduped.
@orsinium orsinium merged commit b5993eb into life4:master Apr 23, 2024
@orsinium
Copy link
Copy Markdown
Member

Thank you! You're right, it looks like a copy-paste of Dedup :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants