So I’ve been putting some work into
pcwalton/rustfmt and feel like it’s in a place, especially after #15339 lands, where we can get the pretty printer component (the only component, atm) into great shape and have it be suitable for public consumption.
The issue is that, beyond “four spaces, no tabs” and naming conventions, there isn’t much in the way of official rust style guidence.
There’s a lot of stuff to cover, like:
- when newlines are approp.
- is 100 chars a hard and fast limit (this is something that could be supported into a [heavily refactored] formatter w/ backtracking)?
- collapsing parens for empty
matcharms (something I’ve already added that isn’t in a style guide)… should we also collapse empty function blocks?
- should we transform identifiers that don’t conform to the naming conventions?
- we have lints for needless parens, but should we put this in the style guide?
- etc, etc
There’s a lot of stuff out there. Much of it is held in the heads of people who write lots of rust and/or have spent enough time in the stdlib to know conventions. There’s a lot of things that aren’t in Notes: Style Guide…
So I guess my question: Should we draft an official style guide as part of the docs? What should go in? What should be left out? I’m not sure where to initiate this conversation or how the styleguide should be created and maintained. Would be great of some stakeholder would be willing to make a proclamation on this.
An obvious source of inspiration/scope would be Google’s C++ style guide at https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml . Please feel free to share other style-guides that you think would be germaine to this discussion.
(Also any discussion about the eventual scope of a feature-complete
rustfmt should be swell)