Search⌘ K

Rust's Built-in Functions

Explore Rust's built-in string functions to manage user input effectively. Learn to trim unwanted characters like carriage returns and convert strings to lowercase. This lesson enhances your ability to handle text input robustly in Rust programs.

The program’s output looks good on screen, but it contains a subtle bug. The string contains some extra characters representing the “ENTER” key. We can see this by replacing our last println! call with the following:

Rust 1.40.0
println!("{:?}", name);

Replacing the {} placeholder with {:?} ...