canonical / rust-best-practices

A set of guidelines to avoid arguments over code-quality
GNU General Public License v3.0
27 stars 0 forks source link

Feedback: People are bad at keeping lists in their own minds #2

Open niemeyer opened 1 month ago

niemeyer commented 1 month ago

Still haven't finished reviewed the whole document, but caught this in a reference from a PR:

Derived items should be ordered as follows:

Copy Clone Debug PartialEq Eq PartialOrd Ord Other standard traits, ordered lexicographically Third party traits, ordered lexicographically

Expecting people to remember what is standard or not is reasonable, and also somewhat implied by the fact they have to import them from somewhere. With that said, expecting people to keep the exact order for the first 7 items doesn't seem reasonable.

What is the underlying rationale here? If there is one, that's what we need to explain and people must keep in mind. Where there is none, it should be mechanical instead of memorized.

TheSignPainter98 commented 2 weeks ago

This is a very good point, I completely agree. When writing this, I wasn't afraid of using lists as I was under the working assumption that this doc would function for both humans and for some tool to mechanically check many of these. This feels awkward though and leads to one or two situations where humans (the important readers) have to read stuff which isn't really written for them. It's definitely better to move more pedantic lists like this out of this doc to keep things people oriented.

For the list above, the existing (missing) rationale here goes as follows:

This is quite complex though, perhaps something like the following could strike a better balance between human-friendliness and exhaustiveness: