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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions