<pre><codeclass="language-text">Please type something, or x to escape:
something
You wrote something
@ -198,13 +195,9 @@ You wrote x
x
You wrote x
<spanclass="boring">}
</span></code></pre></pre>
</code></pre>
<p>It takes our input and gives it back, and it even knows that we typed <code>x</code>. But it doesn't exit the program. The only way to get out is to close the window, or type ctrl and c. Let's change the <code>{}</code> to <code>{:?}</code> in <code>println!</code> to get more information (or you could use <code>dbg!(&input_string)</code> if you like that macro). Now it says:</p>
<pre><codeclass="language-text">Please type something, or x to escape:
something
You wrote "something\r\n"
Something else
@ -213,8 +206,7 @@ x
You wrote "x\r\n"
x
You wrote "x\r\n"
<spanclass="boring">}
</span></code></pre></pre>
</code></pre>
<p>This is because the keyboard input is actually not just <code>something</code>, it is <code>something</code> and the <code>Enter</code> key. There is an easy method to fix this called <code>.trim()</code>, which removes all the whitespace. Whitespace, by the way, is all <ahref="https://doc.rust-lang.org/reference/whitespace.html">these characters</a>:</p>
<pre><codeclass="language-text">Please type something, or x to escape:
something
You wrote something
@ -11095,13 +11092,9 @@ You wrote x
x
You wrote x
<spanclass="boring">}
</span></code></pre></pre>
</code></pre>
<p>It takes our input and gives it back, and it even knows that we typed <code>x</code>. But it doesn't exit the program. The only way to get out is to close the window, or type ctrl and c. Let's change the <code>{}</code> to <code>{:?}</code> in <code>println!</code> to get more information (or you could use <code>dbg!(&input_string)</code> if you like that macro). Now it says:</p>
<pre><codeclass="language-text">Please type something, or x to escape:
something
You wrote "something\r\n"
Something else
@ -11110,8 +11103,7 @@ x
You wrote "x\r\n"
x
You wrote "x\r\n"
<spanclass="boring">}
</span></code></pre></pre>
</code></pre>
<p>This is because the keyboard input is actually not just <code>something</code>, it is <code>something</code> and the <code>Enter</code> key. There is an easy method to fix this called <code>.trim()</code>, which removes all the whitespace. Whitespace, by the way, is all <ahref="https://doc.rust-lang.org/reference/whitespace.html">these characters</a>:</p>