Skip to content

Nullable should implement opCmp #10743

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

Open
VPanteleev-S7 opened this issue Apr 6, 2025 · 0 comments · May be fixed by #10762
Open

Nullable should implement opCmp #10743

VPanteleev-S7 opened this issue Apr 6, 2025 · 0 comments · May be fixed by #10762

Comments

@VPanteleev-S7
Copy link
Contributor

VPanteleev-S7 commented Apr 6, 2025

std.typecons.Nullable should implement comparison (opCmp). This will allow sorting arrays of nullables, or structs with nullable fields.

Whether or not comparing two nullable objects is meaningful, defining an order (however arbitrary) is useful on its own, as it allows sorting for the purposes of finding unique values or for set comparisons, in a way that's often cheaper than a hash-set.

I think comparing two nullable objects is meaningful though - as with objects and arrays, null objects should sort before non-null ones.

DeterminedSage added a commit to DeterminedSage/phobos that referenced this issue Apr 24, 2025
@DeterminedSage DeterminedSage linked a pull request Apr 24, 2025 that will close this issue
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 a pull request may close this issue.

1 participant