1use std::io::stdin;
2
3const READ_ERROR: &'static str = "Error: unable to read user input";
4
5pub fn read_u8() -> u8
7{
8 let mut input = String::new();
9 stdin().read_line(&mut input).expect(READ_ERROR);
10
11 input.trim().parse::<u8>().expect("Unable to parse input to a u8")
12
13}
14
15pub fn read_line() -> String
17{
18 let mut input = String::new();
19 stdin().read_line(&mut input).expect(READ_ERROR);
20
21 input
22}
23
24pub fn read_line_prompt(msg: &str) -> String
26{
27 println!("{}", msg);
28 read_line()
29}