Did more refacroring and made a better loop for anime as well as error handeling in anime

This commit is contained in:
Zastian Pretorius
2022-07-10 22:34:05 +01:00
parent 361a787f93
commit db1ab32120
9 changed files with 108 additions and 72 deletions

View File

@@ -17,7 +17,13 @@ pub fn int_input(prompt: &str) -> usize {
io::stdin()
.read_line(&mut input)
.expect("Error reading from STDIN");
input.trim().parse::<usize>().unwrap()
//try to parse the input as usize else return max usize
match input.trim().parse::<usize>() {
Ok(i) => i,
Err(_) => {
usize::max_value()
}
}
}
pub fn u16_input(prompt: &str) -> u16 {