refact: remove unwrap() & panic!

This commit is contained in:
Henri Bourcereau 2026-03-01 12:47:42 +01:00
parent 953b5f451a
commit ad157e1626
4 changed files with 177 additions and 52 deletions

View file

@ -71,8 +71,8 @@ impl Player {
}
let points = u8::from_str_radix(&bits[0..4], 2).map_err(|e| e.to_string())?;
let holes = u8::from_str_radix(&bits[4..8], 2).map_err(|e| e.to_string())?;
let can_bredouille = bits.chars().nth(8).unwrap() == '1';
let can_big_bredouille = bits.chars().nth(9).unwrap() == '1';
let can_bredouille = bits.chars().nth(8).ok_or_else(|| "8th bit unreadable")? == '1';
let can_big_bredouille = bits.chars().nth(9).ok_or_else(|| "9th bit unreadable")? == '1';
Ok(Player {
name,