I quote:The trailing newline character, if any, is included in the buffer.
So if you want to remove the trailing white space, use the trim_end() function:
3 Likes
readline() preserves the trailing newline character when you pressed the Enter key, you can use str::trim() to remove it:
println!("{}", name.trim());
To clarify even more, in your code, name = "Anthony\n". Now imagine that replacing {} in your format string.
2 Likes
