need explanation of print behavior
I made a typo while playing around with my first Rust program. So intead of println! I used print! and noticed that it printed text at the very end of my program. I checked the docs and saw this:
Note that stdout is frequently line-buffered by default so it may be necessary to use
to ensure the output is emitted immediately.
But this didn't give me an answer to my question but raised even more questions.
- What does line-buffered mean in this case? It's difficult for me as for a frondtend guy to understand the idea of this.
- The word frequently implies that it doesn't always work the same way. What does such behavoir depends on?
- Why does print! work this way while println! does not? They both come from the same std crate and print to the output. But only
print!has a warning that stdout is frequently line-buffered by default. - How can such behavior be useful? I mean buffering and deferred printing.
Thanks in advance!