diff options
Diffstat (limited to 'crates/shirabe-semver/src/constraint')
4 files changed, 16 insertions, 1 deletions
diff --git a/crates/shirabe-semver/src/constraint/bound.rs b/crates/shirabe-semver/src/constraint/bound.rs index 1a63fc3..8e45023 100644 --- a/crates/shirabe-semver/src/constraint/bound.rs +++ b/crates/shirabe-semver/src/constraint/bound.rs @@ -4,7 +4,7 @@ use anyhow::bail; use shirabe_php_shim as php; -#[derive(Debug, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub struct Bound { version: String, is_inclusive: bool, diff --git a/crates/shirabe-semver/src/constraint/constraint_interface.rs b/crates/shirabe-semver/src/constraint/constraint_interface.rs index 2b2e5e8..980a23a 100644 --- a/crates/shirabe-semver/src/constraint/constraint_interface.rs +++ b/crates/shirabe-semver/src/constraint/constraint_interface.rs @@ -16,4 +16,11 @@ pub trait ConstraintInterface { fn set_pretty_string(&mut self, pretty_string: Option<String>); fn __to_string(&self) -> String; + + // Rust-specific helpers for instanceof checks in MultiConstraint::matches and optimizeConstraints. + fn is_disjunctive(&self) -> bool { + false + } + + fn as_any(&self) -> &dyn std::any::Any; } diff --git a/crates/shirabe-semver/src/constraint/match_all_constraint.rs b/crates/shirabe-semver/src/constraint/match_all_constraint.rs index e877735..4d7b988 100644 --- a/crates/shirabe-semver/src/constraint/match_all_constraint.rs +++ b/crates/shirabe-semver/src/constraint/match_all_constraint.rs @@ -34,6 +34,10 @@ impl ConstraintInterface for MatchAllConstraint { "*".to_string() } + fn as_any(&self) -> &dyn std::any::Any { + self + } + fn get_upper_bound(&self) -> Bound { Bound::positive_infinity() } diff --git a/crates/shirabe-semver/src/constraint/match_none_constraint.rs b/crates/shirabe-semver/src/constraint/match_none_constraint.rs index 5bfc6ea..4add794 100644 --- a/crates/shirabe-semver/src/constraint/match_none_constraint.rs +++ b/crates/shirabe-semver/src/constraint/match_none_constraint.rs @@ -34,6 +34,10 @@ impl ConstraintInterface for MatchNoneConstraint { "[]".to_string() } + fn as_any(&self) -> &dyn std::any::Any { + self + } + fn get_upper_bound(&self) -> Bound { Bound::new("0.0.0.0-dev".to_string(), false) } |
