diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-19 00:10:22 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-19 00:11:03 +0900 |
| commit | c839244d8d09f3036ebfee8eef7eb6b147e593ab (patch) | |
| tree | fe48c94f2c2e62468beef5ff1a8f3cff6adeef4f /crates/shirabe-semver/src/constraint/multi_constraint.rs | |
| parent | 48839250146b217e2756ed3c0e624fd341b54d6c (diff) | |
| download | php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.gz php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.zst php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.zip | |
fix(compile): fix various compile errors
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-semver/src/constraint/multi_constraint.rs')
| -rw-r--r-- | crates/shirabe-semver/src/constraint/multi_constraint.rs | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/crates/shirabe-semver/src/constraint/multi_constraint.rs b/crates/shirabe-semver/src/constraint/multi_constraint.rs index 04e262b..5596cc4 100644 --- a/crates/shirabe-semver/src/constraint/multi_constraint.rs +++ b/crates/shirabe-semver/src/constraint/multi_constraint.rs @@ -2,7 +2,6 @@ use std::cell::RefCell; -use anyhow::bail; use crate::constraint::bound::Bound; use crate::constraint::constraint_interface::ConstraintInterface; @@ -26,26 +25,22 @@ impl std::fmt::Debug for MultiConstraint { } impl MultiConstraint { - pub fn new( - constraints: Vec<Box<dyn ConstraintInterface>>, - conjunctive: bool, - ) -> anyhow::Result<Self> { - if constraints.len() < 2 { - bail!( - "Must provide at least two constraints for a MultiConstraint. Use \ + pub fn new(constraints: Vec<Box<dyn ConstraintInterface>>, conjunctive: bool) -> Self { + assert!( + constraints.len() >= 2, + "Must provide at least two constraints for a MultiConstraint. Use \ the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use \ MultiConstraint::create() which optimizes and handles those cases automatically." - ); - } + ); - Ok(Self { + Self { constraints, pretty_string: None, string: RefCell::new(None), conjunctive, lower_bound: RefCell::new(None), upper_bound: RefCell::new(None), - }) + } } pub fn get_constraints(&self) -> &[Box<dyn ConstraintInterface>] { @@ -123,7 +118,7 @@ impl MultiConstraint { return Ok(constraints.into_iter().next().unwrap()); } - Ok(Box::new(MultiConstraint::new(constraints, conjunctive)?)) + Ok(Box::new(MultiConstraint::new(constraints, conjunctive))) } // Returns the (possibly optimized) constraints and the effective conjunctive flag. @@ -163,16 +158,13 @@ impl MultiConstraint { && right1.starts_with('<') && left1.get(2..) == right0.get(3..) { - Some(Box::new( - MultiConstraint::new( - vec![ - l_mc.constraints[0].clone_box(), - r_mc.constraints[1].clone_box(), - ], - true, - ) - .unwrap(), - ) + Some(Box::new(MultiConstraint::new( + vec![ + l_mc.constraints[0].clone_box(), + r_mc.constraints[1].clone_box(), + ], + true, + )) as Box<dyn ConstraintInterface>) } else { None |
