Skip to content

There should be some way to generate default implementations of the cmp::Eq and cmp::Ord traits (deriving?). #3434

Closed
@Dretch

Description

@Dretch

Now that rust uses the cmp::Eq and cmp::Ord traits for comparisons, there is often lots of error-prone boilerplate required to write impls of these traits. For example look at all the Eq impls in src/libsyntax/ast.rs.

It would good to have some way to auto-generate impls that compare values in the same way that the old polymorphic comparison functions did. This would be similar to the deriving feature of Haskell: http://en.wikibooks.org/wiki/Haskell/Classes_and_types#Deriving.

The syntax might look something like:

struct Bob deriving Eq, Ord {
    some: Boo,
    struct: Foo,
    fields: Hoo,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions