From 51fce38f297000b0849c4f34672d417708d62747 Mon Sep 17 00:00:00 2001 From: Dhghomon Date: Wed, 3 Feb 2021 10:32:37 +0000 Subject: [PATCH] deploy: 816acf86d535bf0f92b38e7205023c3709ba2e15 --- Chapter_66.html | 20 ++++++-------------- print.html | 20 ++++++-------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/Chapter_66.html b/Chapter_66.html index 2acaf56..e3455ae 100644 --- a/Chapter_66.html +++ b/Chapter_66.html @@ -180,10 +180,7 @@ fn main() { }

Here is what an output output looks like:

-

-#![allow(unused)]
-fn main() {
-Please type something, or x to escape:
+
Please type something, or x to escape:
 something
 You wrote something
 
@@ -198,13 +195,9 @@ You wrote x
 
 x
 You wrote x
-}
-
+

It takes our input and gives it back, and it even knows that we typed x. 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 {} to {:?} in println! to get more information (or you could use dbg!(&input_string) if you like that macro). Now it says:

-

-#![allow(unused)]
-fn main() {
-Please type something, or x to escape:
+
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"
-}
-
+

This is because the keyboard input is actually not just something, it is something and the Enter key. There is an easy method to fix this called .trim(), which removes all the whitespace. Whitespace, by the way, is all these characters:

U+0009 (horizontal tab, '\t')
 U+000A (line feed, '\n')
@@ -229,7 +221,7 @@ U+2028 (line separator)
 U+2029 (paragraph separator)
 

So that will turn x\r\n into just x. Now it works:

-
use std::io;
+
use std::io;
 
 fn main() {
     println!("Please type something, or x to escape:");
@@ -242,7 +234,7 @@ fn main() {
     }
     println!("See you later!");
 }
-
+

Now it will print:

Please type something, or x to escape:
 something
diff --git a/print.html b/print.html
index 50baa71..02aa2cd 100644
--- a/print.html
+++ b/print.html
@@ -11077,10 +11077,7 @@ fn main() {
 }
 

Here is what an output output looks like:

-

-#![allow(unused)]
-fn main() {
-Please type something, or x to escape:
+
Please type something, or x to escape:
 something
 You wrote something
 
@@ -11095,13 +11092,9 @@ You wrote x
 
 x
 You wrote x
-}
-
+

It takes our input and gives it back, and it even knows that we typed x. 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 {} to {:?} in println! to get more information (or you could use dbg!(&input_string) if you like that macro). Now it says:

-

-#![allow(unused)]
-fn main() {
-Please type something, or x to escape:
+
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"
-}
-
+

This is because the keyboard input is actually not just something, it is something and the Enter key. There is an easy method to fix this called .trim(), which removes all the whitespace. Whitespace, by the way, is all these characters:

U+0009 (horizontal tab, '\t')
 U+000A (line feed, '\n')
@@ -11126,7 +11118,7 @@ U+2028 (line separator)
 U+2029 (paragraph separator)
 

So that will turn x\r\n into just x. Now it works:

-
use std::io;
+
use std::io;
 
 fn main() {
     println!("Please type something, or x to escape:");
@@ -11139,7 +11131,7 @@ fn main() {
     }
     println!("See you later!");
 }
-
+

Now it will print:

Please type something, or x to escape:
 something