How to clear the terminal screen in Rust after a new line is printed?
<p>I have printed some text using <code>println!</code> and now I need to clear the terminal and write the new text instead of the old. How can I clear all the current text from terminal?</p>
<p>I have tried this code, but it only clears the current line and <code>1</code> is still in the output.</p>
<pre><code>fn main() {
    println!(&quot;1&quot;);
    print!(&quot;2&quot;);
    print!(&quot;\r&quot;);
}
</code></pre>