From dbdecaf5a1c54a876b7ee0153d58dd39b1080f97 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 23 May 2026 23:14:52 +0900 Subject: refactor(semver): change ConstraintInterface to a closed enum Replace the dyn ConstraintInterface trait objects with an AnyConstraint enum closing over its four implementors (Simple, Multi, MatchAll, MatchNone), mirroring the earlier Rule enum conversion. Rename constraint.rs to simple_constraint.rs to match the renamed Constraint type. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/shirabe/src/dependency_resolver/default_policy.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/src/dependency_resolver/default_policy.rs') diff --git a/crates/shirabe/src/dependency_resolver/default_policy.rs b/crates/shirabe/src/dependency_resolver/default_policy.rs index c24e382..cc33b81 100644 --- a/crates/shirabe/src/dependency_resolver/default_policy.rs +++ b/crates/shirabe/src/dependency_resolver/default_policy.rs @@ -5,7 +5,8 @@ use std::cell::RefCell; use indexmap::IndexMap; use shirabe_semver::compiling_matcher::CompilingMatcher; -use shirabe_semver::constraint::Constraint; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; use crate::dependency_resolver::PolicyInterface; use crate::dependency_resolver::Pool; @@ -209,14 +210,16 @@ impl PolicyInterface for DefaultPolicy { if (a.is_dev() && a.get_version().starts_with("dev-")) || (b.is_dev() && b.get_version().starts_with("dev-")) { - let constraint = Constraint::new(operator, b.get_version()); - let version = Constraint::new("==", a.get_version()); + let constraint = + SimpleConstraint::new(operator.to_string(), b.get_version().to_string(), None); + let version = + SimpleConstraint::new("==".to_string(), a.get_version().to_string(), None); return constraint.match_specific(&version, true); } CompilingMatcher::r#match( - &Constraint::new(operator, b.get_version()), - Constraint::OP_EQ, + &SimpleConstraint::new(operator.to_string(), b.get_version().to_string(), None).into(), + SimpleConstraint::OP_EQ, a.get_version().to_string(), ) } -- cgit v1.3.1