Fix whitespace handling after where clause by GuillaumeGomez · Pull Request #98256 · rust-lang/rust (original) (raw)

I still think it's not good style. You are still checking the length of the buffer to see whether print_where_clause did anything: https://github.com/rust-lang/rust/pull/98256/files#diff-c4e61d56ff695cfc762517d170672a9c8650ac815abee6a9e28267a2ff27c8f3R72-R74.

That strongly suggests to me that the logic for "will print_where_clause do anything" should be extracted into its own function. I'm not particularly attached to the iterator idea I proposed above; it could also be a has_where_clause() function.

That will make the code that chooses whether to add a space, newline, or semicolon clearer, since it can check if there is or is not a where clause, and call print_where_clause only in that case; and also emit a space, newline, or semicolon only in that case.