From 716f44031a39c5e43fb441ecc470db76efc23dd4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 14 Jun 2026 11:24:36 +0900 Subject: refactor(pcre): drop Result from Preg method return types The Preg methods panic on PCRE failure (per the file header rationale), so their anyhow::Result wrappers never carried an Err. Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/util/composer_mirror.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/util/composer_mirror.rs') diff --git a/crates/shirabe/src/util/composer_mirror.rs b/crates/shirabe/src/util/composer_mirror.rs index 6f15a13..c0ff8d8 100644 --- a/crates/shirabe/src/util/composer_mirror.rs +++ b/crates/shirabe/src/util/composer_mirror.rs @@ -15,7 +15,7 @@ impl ComposerMirror { pretty_version: Option<&str>, ) -> String { let reference = reference.map(|r| { - if Preg::is_match(r"^([a-f0-9]*|%reference%)$", r).unwrap_or(false) { + if Preg::is_match(r"^([a-f0-9]*|%reference%)$", r) { r.to_string() } else { hash("md5", r) @@ -59,9 +59,7 @@ impl ComposerMirror { r"^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$", url, Some(&mut gh_matches), - ) - .unwrap_or(false) - { + ) { format!( "gh-{}/{}", gh_matches @@ -77,9 +75,7 @@ impl ComposerMirror { r"^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$", url, Some(&mut bb_matches), - ) - .unwrap_or(false) - { + ) { format!( "bb-{}/{}", bb_matches @@ -92,7 +88,7 @@ impl ComposerMirror { .unwrap_or_default(), ) } else { - Preg::replace(r"[^a-z0-9_.-]", "-", url.trim_matches('/')).unwrap_or_default() + Preg::replace(r"[^a-z0-9_.-]", "-", url.trim_matches('/')) }; ["%package%", "%normalizedUrl%", "%type%"] -- cgit v1.3.1