pub struct Requirement { /* private fields */ }Expand description
A single boolean check over some set of cells, attached to a cell.
Its predicate must be a pure, deterministic function of its input values and immutable captured constants, with no externally observable side effects. Equal inputs produce equivalent results or errors. There is no guarantee that the predicate executes, or when or how often it executes.
Implementations§
Source§impl Requirement
impl Requirement
Sourcepub fn new<F>(inputs: Vec<CellId>, input_types: Vec<TypeId>, f: F) -> Self
pub fn new<F>(inputs: Vec<CellId>, input_types: Vec<TypeId>, f: F) -> Self
Creates a requirement from explicit TypeIds and a type-erased predicate.
- Precondition:
inputs.len() == input_types.len(). - Precondition:
fsatisfiesRequirement’s purity contract.
Sourcepub fn from_fn_1<A, F>(input: CellId, f: F) -> Self
pub fn from_fn_1<A, F>(input: CellId, f: F) -> Self
Creates a 1-input requirement from a typed closure.
The TypeId for A is captured automatically. The requirement is validated against
its cell registration when passed to crate::sheet::Sheet::add_requirement.
- Precondition:
fsatisfiesRequirement’s purity contract.
Sourcepub fn from_fn_2<A, B, F>(inputs: [CellId; 2], f: F) -> Self
pub fn from_fn_2<A, B, F>(inputs: [CellId; 2], f: F) -> Self
Creates a 2-input requirement from a typed closure.
inputs[0] maps to A and inputs[1] maps to B. TypeIds are captured
automatically. The requirement is validated when passed to
crate::sheet::Sheet::add_requirement.
- Precondition:
fsatisfiesRequirement’s purity contract.