From ade8020d851693c81e6fa09e6970a29e137700a0 Mon Sep 17 00:00:00 2001 From: pawurb Date: Fri, 25 Oct 2024 13:23:51 +0200 Subject: [PATCH] Dont panic if invalid desc --- bin/main.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/main.rs b/bin/main.rs index d663b50..536d350 100644 --- a/bin/main.rs +++ b/bin/main.rs @@ -220,12 +220,14 @@ async fn execute() -> Result<(), PgExtrasError> { } fn extract_desc(desc: &str) -> String { - let start = desc.find("/*").unwrap(); - let end = desc.find("*/").unwrap(); - let extracted = &desc[start + 2..end]; - let mut trimmed = extracted.trim().to_string(); - if trimmed.ends_with('.') { - trimmed.pop(); + if let (Some(start), Some(end)) = (desc.find("/*"), desc.find("*/")) { + let extracted = &desc[start + 2..end]; + let mut trimmed = extracted.trim().to_string(); + if trimmed.ends_with('.') { + trimmed.pop(); + } + trimmed + } else { + desc.to_string() } - trimmed }