From f48a96e64d7952f10cc9fda770574d6fa7fe5f01 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 3 Jul 2024 19:43:38 +0200 Subject: [PATCH] refactor: Extract func to print list of missing messages --- src/main.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6d22775..89ed0b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -498,6 +498,16 @@ fn main() -> Result<(), Box> { .to_string(), ); + fn print_missing_ids(missing_ids: &[&String], term: &Term) { + missing_ids.iter().sorted().for_each(|&item| { + let _ = term.write_line(&format!( + "{} ({})", + item, + to_database_id(item).unwrap_or("?".into()) + )); + }); + } + if db_meldungen.len() != xml_meldungen.len() { let _ = term.write_line( &style("\nNicht übereinstimmende Anzahl an Meldungen:") @@ -522,13 +532,7 @@ fn main() -> Result<(), Box> { .to_string(), ); - missing_db_ids.iter().sorted().for_each(|&item| { - let _ = term.write_line(&format!( - "{} ({})", - item, - to_database_id(item).unwrap_or("?".into()) - )); - }); + print_missing_ids(&missing_db_ids, &term); } if !missing_xml_ids.is_empty() { @@ -538,13 +542,7 @@ fn main() -> Result<(), Box> { .to_string(), ); - missing_xml_ids.iter().sorted().for_each(|&item| { - let _ = term.write_line(&format!( - "{} ({})", - item, - to_database_id(item).unwrap_or("?".into()) - )); - }); + print_missing_ids(&missing_xml_ids, &term); } }