Don't panic on a missing 3rd argument, use the default

This commit is contained in:
Juergen Stuber
2024-10-19 15:51:36 +02:00
parent fa22a5e838
commit e51336b3f2
8 changed files with 44 additions and 14 deletions

View File

@ -240,7 +240,7 @@ where
}
}
const DEFAULT_ARG: isize = 16;
const DEFAULT_ARG: usize = 10;
fn main() -> std::io::Result<()> {
let args = args().collect::<Vec<_>>();
@ -248,7 +248,11 @@ fn main() -> std::io::Result<()> {
let x_size = args[1].parse::<i64>().unwrap();
let y_size = args[2].parse::<i64>().unwrap();
let arg = args[3].parse::<isize>().unwrap_or(DEFAULT_ARG);
let arg = if let Some(s) = args.get(3) {
s.parse::<usize>().unwrap_or(DEFAULT_ARG)
} else {
DEFAULT_ARG
};
eprintln!("screen size {}x{}, arg {}", x_size, y_size, arg);
let mut rng = thread_rng();