Macro catch_input::input
source · [−]macro_rules! input {
($x:tt) => { ... };
($x:expr) => { ... };
}
Expand description
Macro that returns a trimmed String
containing the user input from standard input.
You may pass an argument to be used as a prompt, you may use a FnOnce
or a type with the [Display
] trait implemented.
Example
let input_a = input!("InputA => ");
let input_b = input!(|| { print!("InputB => "); });
assert!(input_a, String::from("Hello"))
assert!(input_b, String::from("World"))
/*
$ cargo run
InputA => Hello
InputB => World
*/