Consider the example (does not build):
use std::io::{self, Write};
fn main() {
io::stdout().write(b"Please enter your name: ");
io::stdout().flush();
let mut name = String::new();
io::stdin().read_line(&mut name);
name = *name.trim();
println!("Hello, {}!", name);
}
Why do I get the following error?
error[E0308]: mismatched types
--> src/main.rs:8:12
|
8 | name = *name.trim();
| ^^^^^^^^^^^^ expected struct `std::string::String`, found str
|
= note: expected type `std::string::String`
= note: found type `str`