Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rust: Ask your name
/* Ask the user for their name */
fn ask_name(prompt: ~str) -> ~str {
println(prompt);
return io::stdin().read_line();
}
fn main() {
let name = ask_name(~"What is your name?");
println(fmt!("Hello %s", name));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.