write!
is quite magical for Rust. It is completely duck-typed — it doesn't use Write
traits, it takes anything that compiles with .write_fmt(args)
appended to it. It doesn't even care about the function type or return type. It takes even bogus signatures like fn write_fmt(&self, f: impl Sized) -> ()
.
Compared to that format_args!
is pretty tame and well-behaved.
If (eh, can't).format_args!
could be made to borrow its arguments for a longer lifetime…