refactor: better file hierarchy

This commit is contained in:
justchokingaround
2022-07-18 04:05:27 +02:00
13 changed files with 449 additions and 126 deletions

View File

@@ -1,5 +1,4 @@
use std::io::{self, Write};
pub fn string_input(prompt: &str) -> String {
print!("{}", prompt);
let mut input = String::new();
@@ -17,15 +16,21 @@ 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 {
print!("{}", prompt);
let mut input = String::new();
let _ = io::stdout().flush();
io::stdin()
.read_line(&mut input)
.expect("Error reading from STDIN");
input.trim().parse::<u16>().unwrap()
}
//pub fn u16_input(prompt: &str) -> u16 {
// print!("{}", prompt);
// let mut input = String::new();
// let _ = io::stdout().flush();
// io::stdin()
// .read_line(&mut input)
// .expect("Error reading from STDIN");
// input.trim().parse::<u16>().unwrap()
//}