Trait contrafact::Fact

source ·
pub trait Fact<'a, T>where
    T: Bounds<'a>,{
    // Required methods
    fn mutate(&self, obj: T, g: &mut Generator<'a>) -> Mutation<T>;
    fn advance(&mut self, obj: &T);

    // Provided methods
    fn check(&self, obj: &T) -> Check { ... }
    fn satisfy(&mut self, obj: T, g: &mut Generator<'a>) -> ContrafactResult<T> { ... }
    fn build_fallible(&mut self, g: &mut Generator<'a>) -> ContrafactResult<T> { ... }
    fn build(&mut self, g: &mut Generator<'a>) -> 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§

source

fn mutate(&self, obj: T, g: &mut Generator<'a>) -> Mutation<T>

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

source

fn advance(&mut self, obj: &T)

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§

source

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

Assert that the constraint is satisfied for given data

source

fn satisfy(&mut self, obj: T, g: &mut Generator<'a>) -> ContrafactResult<T>

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

source

fn build_fallible(&mut self, g: &mut Generator<'a>) -> ContrafactResult<T>

Build a new value such that it satisfies the constraint

source

fn build(&mut self, g: &mut Generator<'a>) -> T

Build a new value such that it satisfies the constraint, panicking on error

Implementations on Foreign Types§

source§

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

source§

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

source§

fn mutate(&self, obj: T, g: &mut Generator<'a>) -> Mutation<T>

source§

fn advance(&mut self, obj: &T)

source§

impl<'a, T, F> Fact<'a, T> for Box<F>where T: Bounds<'a>, F: Fact<'a, T> + ?Sized,

source§

fn mutate(&self, obj: T, g: &mut Generator<'a>) -> Mutation<T>

source§

fn advance(&mut self, obj: &T)

source§

impl<'a, T, F> Fact<'a, T> for Vec<F>where T: Bounds<'a>, F: Fact<'a, T>,

source§

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

source§

fn mutate(&self, obj: T, g: &mut Generator<'a>) -> Mutation<T>

source§

fn advance(&mut self, obj: &T)

Implementors§

source§

impl<'a, O, T, F> Fact<'a, O> for LensFact<'a, O, T, F>where T: Bounds<'a>, O: Bounds<'a> + Clone, F: Fact<'a, T>,

source§

impl<'a, O, T, F> Fact<'a, O> for PrismFact<'a, O, T, F>where T: Bounds<'a> + Clone, O: Bounds<'a>, F: Fact<'a, T>,

source§

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

source§

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