Skip to main content

GenOptions

Struct GenOptions 

Source
pub struct GenOptions {
    pub max_depth: usize,
    pub spread: usize,
    pub coverage: bool,
    pub preserve_case: bool,
    pub max_output_len: Option<usize>,
    pub max_steps: Option<u64>,
}
Expand description

How to generate.

Fields§

§max_depth: usize

How deep to recurse before switching to witness mode. Default DEFAULT_GEN_DEPTH.

This is a steering budget, not a safety limit: exhausting it does not fail, it makes the walk take the shortest derivation it knows. The safety limits are GenOptions::max_output_len and GenOptions::max_steps.

§spread: usize

How many repetitions beyond the minimum to consider. Default DEFAULT_SPREAD.

A repetition takes a count uniformly from min..=min(max, min + spread), so *"a" with the default produces nought to three characters rather than an unbounded run.

§coverage: bool

Steer towards branches that have not been taken yet, rather than choosing randomly.

With this set, and subject to the resource limits, each successful call covers at least one new coverage unit while any reachable one remains uncovered — so full coverage takes at most uncovered(rule) calls. That is a guarantee rather than a probability, and it does not depend on GenOptions::max_depth (D10, D38).

§preserve_case: bool

Emit case-insensitive strings exactly as written, rather than varying their case.

Varying case is the more useful default for a fuzzer — "abc" really does match AbC — but it makes output unpredictable, so a test that compares generated text against an expected string wants this set.

§max_output_len: Option<usize>

Give up once the output reaches this many scalar values. Default DEFAULT_MAX_OUTPUT_LEN.

Finite by default, because termination alone does not make generation practical: a grammar can demand a gigabyte without being wrong (D29).

§max_steps: Option<u64>

Give up after visiting this many nodes. Default DEFAULT_MAX_STEPS.

Trait Implementations§

Source§

impl Clone for GenOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GenOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GenOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for GenOptions

Source§

impl PartialEq for GenOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GenOptions

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.