diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-23 23:14:52 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-23 23:15:14 +0900 |
| commit | dbdecaf5a1c54a876b7ee0153d58dd39b1080f97 (patch) | |
| tree | f13f2ced03c803dcbc42a5672458b3cb19ff0f30 /crates/shirabe/src/package/alias_package.rs | |
| parent | f5b987a00712211b7ce56300851182bda904e97b (diff) | |
| download | php-shirabe-dbdecaf5a1c54a876b7ee0153d58dd39b1080f97.tar.gz php-shirabe-dbdecaf5a1c54a876b7ee0153d58dd39b1080f97.tar.zst php-shirabe-dbdecaf5a1c54a876b7ee0153d58dd39b1080f97.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package/alias_package.rs')
| -rw-r--r-- | crates/shirabe/src/package/alias_package.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/crates/shirabe/src/package/alias_package.rs b/crates/shirabe/src/package/alias_package.rs index 0d687a1..e9b5dbf 100644 --- a/crates/shirabe/src/package/alias_package.rs +++ b/crates/shirabe/src/package/alias_package.rs @@ -3,7 +3,8 @@ use chrono::{DateTime, Utc}; use indexmap::IndexMap; use shirabe_php_shim::{PhpMixed, in_array}; -use shirabe_semver::constraint::Constraint; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; use crate::package::BasePackage; use crate::package::Link; @@ -177,18 +178,18 @@ impl AliasPackage { for link in &links { // link is self.version, but must be replacing also the replaced version if link.get_pretty_constraint().unwrap_or("") == "self.version" { - let mut constraint = Constraint::new("=", &self.version); + let constraint = SimpleConstraint::new( + "=".to_string(), + self.version.to_string(), + Some(pretty_version.clone()), + ); let new_link = Link::new( link.get_source().to_string(), link.get_target().to_string(), - Box::new(constraint.clone()), + constraint.into(), Some(link_type.to_string()), Some(pretty_version.clone()), ); - shirabe_semver::constraint::ConstraintInterface::set_pretty_string( - &mut constraint, - Some(pretty_version.clone()), - ); new_links.push(new_link); } } @@ -200,18 +201,18 @@ impl AliasPackage { if link_type == Link::TYPE_REQUIRE { self.has_self_version_requires = true; } - let mut constraint = Constraint::new("=", &self.version); + let constraint = SimpleConstraint::new( + "=".to_string(), + self.version.to_string(), + Some(pretty_version.clone()), + ); let new_link = Link::new( links[index].get_source().to_string(), links[index].get_target().to_string(), - Box::new(constraint.clone()), + constraint.into(), Some(link_type.to_string()), Some(pretty_version.clone()), ); - shirabe_semver::constraint::ConstraintInterface::set_pretty_string( - &mut constraint, - Some(pretty_version.clone()), - ); links[index] = new_link; } } |
