Description
When a method does not have trait bounds, it is displayed all on one line. When a method has just one trait bound, it takes four lines:
fn by_ref(&mut self) -> &mut Self
where
Self: Sized,
{ ... }
There are some conflicting priorities here: On the one hand, it's nice for the layout to match what rustfmt does. On the other hand, it's good to use spacing to emphasize the parts of the documentation that are important. For instance, the { ... }
has a whole line to itself to convey one bit of information: this is a provided method, not a required one. Spacing is also useful to show that parts of the display are related to each other. In the above, it's not visually clear whether { ... }
is part of by_ref
or some independent item.
I propose we change to this for methods with one trait bound:
fn by_ref(&mut self) -> &mut Self
where Self: Sized { ... }
And this for methods with multiple trait bounds:
fn by_ref(&mut self, other: T) -> &mut Self
where Self: Sized,
T: Read { ... }
Screen shot of nightly: https://doc.rust-lang.org/nightly/std/io/trait.Read.html