Skip to content

Nullable should implement opCmp #10743

Open
@VPanteleev-S7

Description

@VPanteleev-S7

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.

Activity

added a commit that references this issue on Apr 24, 2025
149465f
linked a pull request that will close this issue on Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @VPanteleev-S7

      Issue actions

        Nullable should implement opCmp · Issue #10743 · dlang/phobos