Skip to main content

Requirement

Struct Requirement 

Source
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

Source

pub fn new<F>(inputs: Vec<CellId>, input_types: Vec<TypeId>, f: F) -> Self
where F: Fn(&[&dyn Any]) -> Result<bool, Error> + 'static,

Creates a requirement from explicit TypeIds and a type-erased predicate.

  • Precondition: inputs.len() == input_types.len().
  • Precondition: f satisfies Requirement’s purity contract.
Source

pub fn from_fn_1<A, F>(input: CellId, f: F) -> Self
where A: Any + 'static, F: Fn(&A) -> Result<bool, Error> + 'static,

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: f satisfies Requirement’s purity contract.
Source

pub fn from_fn_2<A, B, F>(inputs: [CellId; 2], f: F) -> Self
where A: Any + 'static, B: Any + 'static, F: Fn(&A, &B) -> Result<bool, Error> + 'static,

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: f satisfies Requirement’s purity contract.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.