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/semver.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'crates/shirabe-semver/src/semver.rs') diff --git a/crates/shirabe-semver/src/semver.rs b/crates/shirabe-semver/src/semver.rs index 62f50b6..2314069 100644 --- a/crates/shirabe-semver/src/semver.rs +++ b/crates/shirabe-semver/src/semver.rs @@ -3,7 +3,8 @@ use std::sync::OnceLock; use crate::comparator::Comparator; -use crate::constraint::Constraint; +use crate::constraint::AnyConstraint; +use crate::constraint::SimpleConstraint; use crate::version_parser::VersionParser; pub struct Semver; @@ -19,7 +20,12 @@ impl Semver { pub fn satisfies(version: String, constraints: String) -> anyhow::Result { let version_parser = Self::version_parser(); - let provider = Constraint::new("==".to_string(), version_parser.normalize(&version, None)?); + let provider = SimpleConstraint::new( + "==".to_string(), + version_parser.normalize(&version, None)?, + None, + ) + .into(); let parsed_constraints = version_parser.parse_constraints(&constraints)?; Ok(parsed_constraints.matches(&provider)) } -- cgit v1.3.1