TIL that print!(…) is not the same as write!(stdout(), …).unwrap()
While doing some work with io redirection, I learned something surprising about how the standard streams work: print!(…) is not equivalent to write!(io::stdout(), …).unwrap(). The key difference is output capture: when running tests, cargo / rust advertise the ability to capture stdout and stderr and present it only on test failures (togglable with --no-capture); as it turns out, this only works when using the standard printing macros and does not apply to direct writes to the stdout() object. Same thing applies to println!, eprint!, etc. This discrepancy isn’t mentioned at all in the docs for the formatting macros or standard streams, and the relevant docs in cargo describe only that “stdout and stderr can be captured”.