[−][src]Macro lab_grader::prompt
Calls prompt
, then tries to parse the input
into the provided type. If parsing fails, it will print an error message
and then quit the current process.
If you wish to deal with the error yourself instead of quitting,
then call prompt
, then parse
yourself.
Example
#[macro_use] extern crate lab_grader; use lab_grader::helpers; fn main() { let string = prompt!("Enter a string: ", String); println!("{}", string); let number = prompt!("Enter a number: ", u32); println!("{}", number); let another = prompt!("Enter another number: ", u32); println!("{}", another); }
They input:
Enter a string: Here's a string
Here's a string
Enter a number: 123
123
Enter another number: not a number
Could not parse input