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