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

C-COMMON-TRAITS and enums #99

Open
behnam opened this issue Jul 6, 2017 · 0 comments
Open

C-COMMON-TRAITS and enums #99

behnam opened this issue Jul 6, 2017 · 0 comments
Labels
amendment Amendments to existing guidelines clarification I-nominated Indicates that an issue has been nominated for discussion during a team meeting.

Comments

@behnam
Copy link
Contributor

behnam commented Jul 6, 2017

Can we expand the language of C-COMMON-TRAITS to help making decisions for enum types implementing non-trivial traits, specially Ord/PartialOrd and Default?

I think the question I face in designing the API is: how Ord/PartialOrd and Default are used in common cases, specifically the standard library, and what functionalities users will be missing without the trait implementation.

For example, I have a plain enum that has 25 variants. Ordering doesn't have any straightforward meaning for the type internally, but deriving Ord/PartialOrd on the (currently) alphabetically-ordered list is easy to do.

A similar situation with Default. This enum is representing a character property, which does have a default value for non-assigned Unicode code points. (Technically, the default value is different for some specific Unicode blocks, but there's on generic default value stated in the specs.) However, the implementation already takes that into account and always returns a value. And, the enum values are always fetched from a character, so there's no standalone instantiation which would require a Default value. So, again, obvious to derive, but almost meaning-less in usage.

In Rust reference docs, it's clear that not providing Hash prevents using the type in HashMap and HashSet types. But, the reference doesn't mention anything about Ord/PartialOrd or Default being used in the standard library.

An alternate would be to put some explanation about these traits in the reference doc to make it more clear how, if at all, they are used in the standard library.

What do you think?

@KodrAus KodrAus added amendment Amendments to existing guidelines I-nominated Indicates that an issue has been nominated for discussion during a team meeting. and removed hacktoberfest labels Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amendment Amendments to existing guidelines clarification I-nominated Indicates that an issue has been nominated for discussion during a team meeting.
Projects
None yet
Development

No branches or pull requests

3 participants