Clippy warning on write! with newline

I'm getting a warning from clippy about using write! with a string that ends in "\n". Here is the warning:

Why is this a warning? The link doesn't give a reason why using writeln! is better. I can't imagine appending is faster.

AFAIK, there is a difference between the two, which is that writeln does an stdout flush at the end. Not flushing can lead to text not appearing in some situations, and manual flushing is easily forgotten. That's most likely why clippy lints this.

They do the same thing.

1 Like

Well, they produce literally same assembly, byte by byte. But writeln!() is more idiomatic and correctly produces \r\n on Windows.