Question: what causes stdout to flush after `main`

Currently, when I write this:

fn main() {
    // No newline
    print!("Hello, World");

I see Hello World printed to stdout after the sleep, when the program finishes. This would imply that there is some mechanism by which the BufWriter is flushed (presumably it's dropped). Does anyone know what that mechanism is or where it happens? Normally, globals aren't dropped at all, even after the program returns (as they are in C++). I wasn't seeing anything obvious in that would cause this to happen in the stdout cast.

1 Like

Found by looking at


Excellent, thank you very much!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.