I'm working on a template engine. As such, I'd like to be able to create an API where I accept a Display, and then write the resulting output into an output buffer. From looking at the documentation, it seems as if there is no stable way to create a Formatter, so in order to write the Display value for multiple things into a single buffer, I'd have to use the formatting macros to create Strings for each thing, then write them into a Write separately.
It appears like I might be able to do something smarter if I'd enable nightly's fmt_internals, but even then it seems to be pretty ugly to set up a longer-lived Formatter.
Is this understanding correct, or are there other ways of doing what I want?
In addition to using write! and format_args!, you can use various wrapper types to make it easier to work with the formatter (through the format traits). One of the most versatile ones is a combinator (Fmt below) that simply gives you access to the formatter in a closure: