Struct OptionMutator

Source
pub struct OptionMutator<T, M0_0>
where T: Clone + 'static, M0_0: Mutator<T>,
{ /* private fields */ }
Expand description

A mutator for Option

Generated by a procedural macro of fuzzcheck

Implementations§

Source§

impl<T, M0_0> OptionMutator<T, M0_0>
where T: Clone + 'static, M0_0: Mutator<T>,

Source

pub fn new(mutator_Some_0: M0_0) -> Self

Trait Implementations§

Source§

impl<T, M0_0> Mutator<Option<T>> for OptionMutator<T, M0_0>
where T: Clone + 'static, M0_0: Mutator<T>,

Source§

type Cache: Clone

Accompanies each value to help compute its complexity and mutate it efficiently.
Source§

type MutationStep: Clone

Contains information about what mutations have already been tried.
Source§

type ArbitraryStep: Clone

Contains information about what arbitrary values have already been generated.
Source§

type UnmutateToken

Describes how to reverse a mutation
Source§

fn initialize(&self)

Must be called after creating a mutator, to initialise its internal state.
Source§

fn default_arbitrary_step(&self) -> Self::ArbitraryStep

The first ArbitraryStep value to be passed to ordered_arbitrary
Source§

fn is_valid(&self, value: &Value) -> bool

Quickly verifies that the value conforms to the mutator’s expectations
Source§

fn validate_value(&self, value: &Value) -> Option<Self::Cache>

Verifies that the value conforms to the mutator’s expectations and, if it does, returns the Cache associated with that value.
Source§

fn default_mutation_step( &self, value: &Value, cache: &Self::Cache, ) -> Self::MutationStep

Returns the first MutationStep associated with the value and cache.
Source§

fn global_search_space_complexity(&self) -> f64

The log2 of the number of values that can be produced by this mutator, or an approximation of this number (e.g. the number of bits that are needed to identify each possible value). Read more
Source§

fn max_complexity(&self) -> f64

The maximum complexity that a value can possibly have.
Source§

fn min_complexity(&self) -> f64

The minimum complexity that a value can possibly have.
Source§

fn complexity(&self, value: &Value, cache: &Self::Cache) -> f64

Computes the complexity of the value. Read more
Source§

fn ordered_arbitrary( &self, step: &mut Self::ArbitraryStep, max_cplx: f64, ) -> Option<(Value, f64)>

Generates an entirely new value based on the given ArbitraryStep. Read more
Source§

fn random_arbitrary(&self, max_cplx: f64) -> (Value, f64)

Generates an entirely new value. Read more
Source§

fn ordered_mutate( &self, value: &mut Value, cache: &mut Self::Cache, step: &mut Self::MutationStep, subvalue_provider: &dyn SubValueProvider, max_cplx: f64, ) -> Option<(Self::UnmutateToken, f64)>

Mutates a value (and optionally its cache) based on the given MutationStep. Read more
Source§

fn random_mutate( &self, value: &mut Value, cache: &mut Self::Cache, max_cplx: f64, ) -> (Self::UnmutateToken, f64)

Mutates a value (and optionally its cache). Read more
Source§

fn unmutate( &self, value: &mut Value, cache: &mut Self::Cache, t: Self::UnmutateToken, )

Undoes a mutation performed on the given value and cache, described by the given UnmutateToken.
Source§

fn visit_subvalues<'a>( &self, value: &'a Value, cache: &'a Self::Cache, visit: &mut dyn FnMut(&'a dyn Any, f64), )

Call the given closure on all subvalues and their complexities.

Auto Trait Implementations§

§

impl<T, M0_0> !Freeze for OptionMutator<T, M0_0>

§

impl<T, M0_0> !RefUnwindSafe for OptionMutator<T, M0_0>

§

impl<T, M0_0> Send for OptionMutator<T, M0_0>
where T: Send, M0_0: Send,

§

impl<T, M0_0> !Sync for OptionMutator<T, M0_0>

§

impl<T, M0_0> Unpin for OptionMutator<T, M0_0>
where T: Unpin, M0_0: Unpin,

§

impl<T, M0_0> UnwindSafe for OptionMutator<T, M0_0>
where T: UnwindSafe, M0_0: UnwindSafe,

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, M> MutatorExt<T> for M
where M: Mutator<T>, T: Clone + 'static,

Source§

fn filter<F>(self, filter: F) -> FilterMutator<Self, F>
where F: Fn(&T) -> bool + 'static,

Create a mutator which wraps self but only produces values for which the given closure returns true
Source§

fn map<To, Map, Parse>( self, map: Map, parse: Parse, ) -> MapMutator<T, To, Self, Parse, Map, fn(&To, f64) -> f64>
where To: Clone + 'static, Map: Fn(&T) -> To, Parse: Fn(&To) -> Option<T>,

Create a mutator which wraps self and transforms the values generated by self using the map closure. The second closure, parse, should apply the opposite transformation.
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.