Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FuzzyNum example in std::cmp documentation seems to violate PartialEq requirements #24173

Closed
niconii opened this issue Apr 7, 2015 · 3 comments · Fixed by #24628
Closed

FuzzyNum example in std::cmp documentation seems to violate PartialEq requirements #24173

niconii opened this issue Apr 7, 2015 · 3 comments · Fixed by #24628

Comments

@niconii
Copy link
Contributor

niconii commented Apr 7, 2015

In the documentation for PartialEq, it mentions that the equality must be symmetric (a == b implies b == a) and transitive (a == b and b == c implies a == c) to satisfy the partial equivalence relation.

However, in std::cmp's documentation, it gives a PartialEq example for a FuzzyNum struct, but this does not appear to be transitive. For example, the fuzzy numbers 20 and 24 are equal, 24 and 28 are equal, but 20 and 28 are not equal.

Is there something I'm missing here, or should the example be rewritten?

@steveklabnik
Copy link
Member

I'm pretty sure it's just a sloppy example.

@sfackler
Copy link
Member

sfackler commented Apr 8, 2015

A range type would be a better thing to use as an example as it would actually be partially ordered.

@pnkfelix
Copy link
Member

pnkfelix commented Apr 8, 2015

(Note this is about partial eq, not ord.)

Range types may work still. Or we could adapt the kernels example from the linked Wikipedia article.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 20, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 20, 2015
Fixes rust-lang#24173 

These docs could all use examples, so for now, let's just remove the bad one, and when I go over this whole module I'll put in better ones.
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 21, 2015
Fixes rust-lang#24173 

These docs could all use examples, so for now, let's just remove the bad one, and when I go over this whole module I'll put in better ones.
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants