Skip to content

use correct naming for the comparison traits and add trait inheritance #12517

Closed
@thestinger

Description

Updated description

The target end point: https://gist.github.com/alexcrichton/10945968

Original issue

  • rename Ord -> PartialOrd
  • rename TotalOrd -> Ord
  • rename Eq -> PartialEq
  • rename TotalEq -> Eq
  • PartialOrd inherits from PartialEq
  • Ord inherits from Eq
  • Ord inherits from PartialOrd
  • Eq inherits from PartialEq
  • remove equals method (TotalEq deriving needs to be redone)
  • deriving Ord also derives PartialOrd
  • deriving Eq also derives PartialEq

An implementation of Eq will simply mean that the PartialEq implementation provides equivalence rather than partial equivalence. An Ord implementation will add a single cmp method and the guarantee of the PartialOrd implementation providing a total order.

This allows code generic over Float to use the operators, since it will inherit from PartialEq and PartialOrd. Code generic over Eq and Ord will also be able to use the operators, despite not being designed to handle a partial order.

Metadata

Assignees

Labels

C-cleanupCategory: PRs that clean code up or issues documenting cleanup.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions