Skip to content

Misleading description of PartialEq derived implementation for enums in docs #97945

Closed
@nirvana-msu

Description

@nirvana-msu

Current docs on PartialEq derive state:

When derived on enums, each variant is equal to itself and not equal to the other variants.

I interpret the above statement as "PartialEq compares enum discriminants", which is not the case.

This is true for enums variants with no data, however for enum variants that are struct-like or tuple struct-like, derived PartialEq actually compares the fields (which is expected) and not just discriminants:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=64530ce03a4506d1e82a1df4d78765ff

Metadata

Metadata

Assignees

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions