pub trait Specification<T: ?Sized> {
// Required method
fn is_satisfied_by(&self, candidate: &T) -> bool;
// Provided methods
fn and<Other>(self, other: Other) -> And<Self, Other>
where Self: Sized,
Other: Specification<T> { ... }
fn or<Other>(self, other: Other) -> Or<Self, Other>
where Self: Sized,
Other: Specification<T> { ... }
fn not(self) -> Not<Self>
where Self: Sized { ... }
}Expand description
A deterministic boolean rule over a borrowed candidate.
Implement this trait for a focused business rule, then compose it with the provided boolean combinators. Evaluation borrows the candidate, so rules do not take ownership of the value they inspect.
Required Methods§
Sourcefn is_satisfied_by(&self, candidate: &T) -> bool
fn is_satisfied_by(&self, candidate: &T) -> bool
Returns whether candidate satisfies this rule.
Provided Methods§
Sourcefn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
fn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
Combines this rule with other using short-circuiting logical AND.
The resulting And evaluates this rule first. It evaluates other
only when this rule returns true.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".