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

Document trait impl behavior #133

Closed
apasel422 opened this issue Mar 4, 2015 · 2 comments
Closed

Document trait impl behavior #133

apasel422 opened this issue Mar 4, 2015 · 2 comments

Comments

@apasel422
Copy link
Contributor

All implementations of (at least) the following traits should specify their exact behavior using a doc comment on the appropriate impl methods:

  • Default -- exactly how the collection is constructed (e.g. by delegating to some other method)
  • Extend -- whether the new elements are inserted in the same order they are yielded from the iterator, and, for maps and sets, what happens in the case that there are duplicates (including what it means for there to be a duplicate)
  • FromIterator -- same requirements as Default and Extend
  • {PartialEq, Eq} -- what constitutes the equivalence relation
  • {PartialOrd, Ord} -- what constitutes the partial/total order

Additionally, all types implementing Iterator should document their ordering invariants (including the case in which there are none).

@Gankra
Copy link
Owner

Gankra commented Mar 4, 2015

Default, Extend, and FromIterator all seem obvious? Default is sugar for new, and Extend and FromIterator are sugar for the simplest insertion.

Eq and Ord, I guess are a bit nontrivial...

@apasel422
Copy link
Contributor Author

Hmm, I guess those three are normally obvious, but {Eq, Ord} seem important to specify, especially because it's so easy to silently break code that is using them.

@Gankra Gankra closed this as completed Mar 18, 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

No branches or pull requests

2 participants