From c839244d8d09f3036ebfee8eef7eb6b147e593ab Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 19 May 2026 00:10:22 +0900 Subject: fix(compile): fix various compile errors Co-Authored-By: Claude Sonnet 4.6 --- crates/shirabe-semver/src/constraint/constraint.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'crates/shirabe-semver/src/constraint/constraint.rs') diff --git a/crates/shirabe-semver/src/constraint/constraint.rs b/crates/shirabe-semver/src/constraint/constraint.rs index f8ff04e..1435139 100644 --- a/crates/shirabe-semver/src/constraint/constraint.rs +++ b/crates/shirabe-semver/src/constraint/constraint.rs @@ -60,22 +60,25 @@ impl Constraint { } } - pub fn new(operator: String, version: String) -> anyhow::Result { - let op_int = Self::trans_op_str(&operator).ok_or_else(|| { - anyhow::anyhow!( + pub fn new(operator: impl Into, version: impl Into) -> Self { + let operator: String = operator.into(); + let op_int = Self::trans_op_str(&operator).unwrap_or_else(|| { + // PHP raises InvalidArgumentException; in the Rust port keep that as a panic + // because invalid operators are programmer errors caught during porting. + panic!( "Invalid operator \"{}\" given, expected one of: {}", operator, Self::get_supported_operators().join(", ") ) - })?; + }); - Ok(Self { + Self { operator: op_int, - version, + version: version.into(), pretty_string: None, lower_bound: Mutex::new(None), upper_bound: Mutex::new(None), - }) + } } pub fn get_version(&self) -> &str { -- cgit v1.3.1