Simplify error-handling in seed generation

This commit is contained in:
Bruno BELANYI 2024-04-06 19:22:16 +01:00
parent a667e6b7f2
commit 7dd0da6628

View file

@ -212,7 +212,8 @@ mod test {
Some((prefix, mid, suffix)) Some((prefix, mid, suffix))
} }
fn array_string(piece_type: &str, values: &[Magic]) -> Result<String, std::fmt::Error> { fn array_string(piece_type: &str, values: &[Magic]) -> String {
let inner = || -> Result<String, std::fmt::Error> {
let mut res = String::new(); let mut res = String::new();
writeln!( writeln!(
@ -231,6 +232,9 @@ mod test {
writeln!(&mut res, "];")?; writeln!(&mut res, "];")?;
Ok(res) Ok(res)
};
inner().unwrap()
} }
#[test] #[test]
@ -243,8 +247,8 @@ mod test {
let original_text = std::fs::read_to_string(file!()).unwrap(); let original_text = std::fs::read_to_string(file!()).unwrap();
let bishop_array = array_string("bishop", &bishop_magics[..]).unwrap(); let bishop_array = array_string("bishop", &bishop_magics[..]);
let rook_array = array_string("rook", &rook_magics[..]).unwrap(); let rook_array = array_string("rook", &rook_magics[..]);
let new_text = { let new_text = {
let start_marker = "// region:sourcegen\n"; let start_marker = "// region:sourcegen\n";