aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-semver/src/constraint/constraint.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-19 00:10:22 +0900
committernsfisis <nsfisis@gmail.com>2026-05-19 00:11:03 +0900
commitc839244d8d09f3036ebfee8eef7eb6b147e593ab (patch)
treefe48c94f2c2e62468beef5ff1a8f3cff6adeef4f /crates/shirabe-semver/src/constraint/constraint.rs
parent48839250146b217e2756ed3c0e624fd341b54d6c (diff)
downloadphp-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.gz
php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.zst
php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.zip
fix(compile): fix various compile errors
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-semver/src/constraint/constraint.rs')
-rw-r--r--crates/shirabe-semver/src/constraint/constraint.rs17
1 files changed, 10 insertions, 7 deletions
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<Self> {
- let op_int = Self::trans_op_str(&operator).ok_or_else(|| {
- anyhow::anyhow!(
+ pub fn new(operator: impl Into<String>, version: impl Into<String>) -> 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 {