Mut String += format_args!(…);

Previous discussion here:

Since then, I became even more convinced that this is a trivial papercut which is important to fix in stdlib.

I like += format_args!() solution because its a clear improvement with basically no downsides. We should go and do it.

I wouldn't want for us to stick with buf += format_args!() as a long-term (10 years from now) solution --- its a clever use of plumbing and a happy coincidence in library design, but it doesn't seem like a sufficiently good first class solution.

Potential long-term alternative is for rust to gain first-class string interpolation syntax, such that we could write

buf += f"Hello, {name}!"

where f"" desugars into something like format_args!.

6 Likes