Consider the following function:
use std::io;
pub fn hello() {
println!("Hello, How are you doing? What your characters name?");
let mut name = String::new();
io::stdin().read_line(&mut name).expect("Failed to read name. What was that name again?");
println!("Welcome to the castle {}", name);
}
How to take the latter println!and turn it into "Welcome to the castle {}".to_string();and replace {}with name(obviously, I need to add -> Stringfunctions to the declaration.)
source
share