Skip to content

Consider adding Ord::le, Ord::lt, etc. to Ord trait #11408

@michaeljklein

Description

@michaeljklein

Problem

  1. <=, <, >, and >= are currently a type of builtin functions that require special handling e.g. in the monomorphizer and during type-checking
  2. Being a type of builtin function, it's not currently possible to optimize <=, etc. in cases where they could be more efficient than e.g. a.cmp(b) != Ordering::Greater

Happy Case

  • Add Ord::le, Ord::lt, etc. to the Ord case with default method implementations as specified in the monomorphizer, e.g.
pub trait Ord {
    fn cmp(self, other: Self) -> Ordering;

    fn le(self, other: Self) -> bool {
        
    }
}

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions