Trait contrafact::Fact[][src]

pub trait Fact<T> where
    T: Bounds, 
{ fn check(&self, obj: &T) -> Check;
fn mutate(&self, obj: &mut T, u: &mut Unstructured<'static>);
fn advance(&mut self, obj: &T); fn satisfy(&mut self, obj: &mut T, u: &mut Unstructured<'static>) { ... }
fn build(&mut self, u: &mut Unstructured<'static>) -> T { ... } }
Expand description

A declarative representation of a constraint on some data, which can be used to both make an assertion (check) or to mold some arbitrary existing data into a shape which passes that same assertion (mutate)

Required methods

fn check(&self, obj: &T) -> Check[src]

Expand description

Assert that the constraint is satisfied (panic if not).

fn mutate(&self, obj: &mut T, u: &mut Unstructured<'static>)[src]

Expand description

Apply a mutation which moves the obj closer to satisfying the overall constraint.

fn advance(&mut self, obj: &T)[src]

Expand description

When checking or mutating a sequence of items, this gets called after each item to modify the state to get ready for the next item.

Provided methods

fn satisfy(&mut self, obj: &mut T, u: &mut Unstructured<'static>)[src]

Expand description

Mutate a value such that it satisfies the constraint. If the constraint cannot be satisfied, panic.

fn build(&mut self, u: &mut Unstructured<'static>) -> T[src]

Expand description

Build a new value such that it satisfies the constraint

Implementations on Foreign Types

impl<T, F: ?Sized> Fact<T> for Box<F> where
    T: Bounds,
    F: Fact<T>, 
[src]

fn check(&self, obj: &T) -> Check[src]

fn mutate(&self, obj: &mut T, u: &mut Unstructured<'static>)[src]

fn advance(&mut self, obj: &T)[src]

impl<T, F> Fact<T> for &mut [F] where
    T: Bounds,
    F: Fact<T>, 
[src]

fn check(&self, obj: &T) -> Check[src]

fn mutate(&self, obj: &mut T, u: &mut Unstructured<'static>)[src]

fn advance(&mut self, obj: &T)[src]

impl<T, F> Fact<T> for Vec<F> where
    T: Bounds,
    F: Fact<T>, 
[src]

fn check(&self, obj: &T) -> Check[src]

fn mutate(&self, obj: &mut T, u: &mut Unstructured<'static>)[src]

fn advance(&mut self, obj: &T)[src]

Implementors

impl<'a, T> Fact<T> for BruteFact<'a, T> where
    T: Bounds, 
[src]

fn check(&self, t: &T) -> Check[src]

fn mutate(&self, t: &mut T, u: &mut Unstructured<'static>)[src]

fn advance(&mut self, _: &T)[src]

impl<'a, T> Fact<T> for MappedFact<'a, T> where
    T: Bounds, 
[src]

fn check(&self, t: &T) -> Check[src]

fn mutate(&self, t: &mut T, u: &mut Unstructured<'static>)[src]

fn advance(&mut self, _: &T)[src]

impl<O, T, F> Fact<O> for LensFact<O, T, F> where
    T: Bounds,
    O: Bounds,
    F: Fact<T>, 
[src]

fn check(&self, obj: &O) -> Check[src]

fn mutate(&self, obj: &mut O, u: &mut Unstructured<'static>)[src]

fn advance(&mut self, obj: &O)[src]

impl<O, T, F> Fact<O> for PrismFact<O, T, F> where
    T: Bounds,
    O: Bounds,
    F: Fact<T>, 
[src]

fn check(&self, o: &O) -> Check[src]

fn mutate(&self, obj: &mut O, u: &mut Unstructured<'static>)[src]

fn advance(&mut self, obj: &O)[src]