pub struct MultiConstraint { /* private fields */ }Expand description
A compound constraint combining multiple constraints with AND or OR.
Implementations§
Source§impl MultiConstraint
impl MultiConstraint
Sourcepub fn new(constraints: Vec<Box<dyn Constraint>>, conjunctive: bool) -> Self
pub fn new(constraints: Vec<Box<dyn Constraint>>, conjunctive: bool) -> Self
Create a new multi-constraint.
conjunctive = true means AND (all must match), false means OR (any must match).
Sourcepub fn create(
constraints: Vec<Box<dyn Constraint>>,
conjunctive: bool,
) -> Box<dyn Constraint>
pub fn create( constraints: Vec<Box<dyn Constraint>>, conjunctive: bool, ) -> Box<dyn Constraint>
Smart constructor that optimizes and handles edge cases.
Returns appropriate type: MatchAll, MatchNone, Single, or Multi.
§Panics
Never panics - the unwrap is only reached when length is exactly 1.
Sourcepub const fn is_conjunctive(&self) -> bool
pub const fn is_conjunctive(&self) -> bool
Check if this is a conjunctive (AND) constraint.
Sourcepub const fn is_disjunctive(&self) -> bool
pub const fn is_disjunctive(&self) -> bool
Check if this is a disjunctive (OR) constraint.
Sourcepub fn constraints(&self) -> &[Box<dyn Constraint>]
pub fn constraints(&self) -> &[Box<dyn Constraint>]
Get the inner constraints.
Trait Implementations§
Source§impl Clone for MultiConstraint
impl Clone for MultiConstraint
Source§impl Constraint for MultiConstraint
impl Constraint for MultiConstraint
Source§fn matches(&self, other: &dyn Constraint) -> bool
fn matches(&self, other: &dyn Constraint) -> bool
Check if this constraint matches/intersects with another.
Source§fn lower_bound(&self) -> Bound
fn lower_bound(&self) -> Bound
Get the lower bound of this constraint.
Source§fn upper_bound(&self) -> Bound
fn upper_bound(&self) -> Bound
Get the upper bound of this constraint.
Source§fn set_pretty_string(&mut self, pretty: String)
fn set_pretty_string(&mut self, pretty: String)
Set a custom pretty string (for preserving user input).
Source§fn pretty_string(&self) -> String
fn pretty_string(&self) -> String
Get a human-readable representation.
Source§fn as_multi(&self) -> Option<&MultiConstraint>
fn as_multi(&self) -> Option<&MultiConstraint>
Try to downcast to
MultiConstraint.Source§fn is_match_all(&self) -> bool
fn is_match_all(&self) -> bool
Check if this is a
MatchAllConstraint.Source§fn is_match_none(&self) -> bool
fn is_match_none(&self) -> bool
Check if this is a
MatchNoneConstraint.Source§fn as_single(&self) -> Option<&SingleConstraint>
fn as_single(&self) -> Option<&SingleConstraint>
Try to downcast to
SingleConstraint.Source§impl Debug for MultiConstraint
impl Debug for MultiConstraint
Auto Trait Implementations§
impl Freeze for MultiConstraint
impl !RefUnwindSafe for MultiConstraint
impl Send for MultiConstraint
impl Sync for MultiConstraint
impl Unpin for MultiConstraint
impl !UnwindSafe for MultiConstraint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more