Constraint

Trait Constraint 

Source
pub trait Constraint:
    Display
    + Debug
    + Send
    + Sync {
    // Required methods
    fn matches(&self, other: &dyn Constraint) -> bool;
    fn lower_bound(&self) -> Bound;
    fn upper_bound(&self) -> Bound;

    // Provided methods
    fn pretty_string(&self) -> String { ... }
    fn set_pretty_string(&mut self, _pretty: String) { ... }
    fn is_match_all(&self) -> bool { ... }
    fn is_match_none(&self) -> bool { ... }
    fn as_single(&self) -> Option<&SingleConstraint> { ... }
    fn as_multi(&self) -> Option<&MultiConstraint> { ... }
}
Expand description

Core trait for all constraint types.

Required Methods§

Source

fn matches(&self, other: &dyn Constraint) -> bool

Check if this constraint matches/intersects with another.

Source

fn lower_bound(&self) -> Bound

Get the lower bound of this constraint.

Source

fn upper_bound(&self) -> Bound

Get the upper bound of this constraint.

Provided Methods§

Source

fn pretty_string(&self) -> String

Get a human-readable representation.

Source

fn set_pretty_string(&mut self, _pretty: String)

Set a custom pretty string (for preserving user input).

Source

fn is_match_all(&self) -> bool

Check if this is a MatchAllConstraint.

Source

fn is_match_none(&self) -> bool

Check if this is a MatchNoneConstraint.

Source

fn as_single(&self) -> Option<&SingleConstraint>

Try to downcast to SingleConstraint.

Source

fn as_multi(&self) -> Option<&MultiConstraint>

Try to downcast to MultiConstraint.

Implementors§