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-semver/src/comparator.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'crates/shirabe-semver/src/comparator.rs') diff --git a/crates/shirabe-semver/src/comparator.rs b/crates/shirabe-semver/src/comparator.rs index 6db06d4..36a4142 100644 --- a/crates/shirabe-semver/src/comparator.rs +++ b/crates/shirabe-semver/src/comparator.rs @@ -1,6 +1,6 @@ //! ref: composer/vendor/composer/semver/src/Comparator.php -use crate::constraint::Constraint; +use crate::constraint::SimpleConstraint; pub struct Comparator; @@ -30,7 +30,10 @@ impl Comparator { } pub fn compare(version1: String, operator: String, version2: String) -> bool { - let constraint = Constraint::new(operator, version2); - constraint.match_specific(&Constraint::new("==".to_string(), version1), true) + let constraint = SimpleConstraint::new(operator, version2, None); + constraint.match_specific( + &SimpleConstraint::new("==".to_string(), version1, None), + true, + ) } } -- cgit v1.3.1