Macro input_macro::input
source · [−]macro_rules! input {
() => { ... };
($($arg:tt)*) => { ... };
}Expand description
Displays the formatted prompt to the standard output
then reads the next line (CR or CRLF) from the standard input,
and returns it as a String.
Panics
Panics if writing to std::io::stdout() fails,
or reading from std::io::stdin() fails.
Examples
let name: String = input!("What's your name? ");
let age: i64 = input!("How old are you today {name}? ").parse().unwrap();
println!(
"In hexadecimal, thats {}{:x}!",
if age < 0 { "-" } else { "" }, age.abs(),
);