in lain/src/new_fuzzed.rs [694:744]
fn new_fuzzed<R: Rng>(mutator: &mut Mutator<R>, constraints: Option<&Constraints<Self::RangeType>>) -> Self {
let min: Self::RangeType;
let max: Self::RangeType;
let weight: Weighted;
// if no min/max were supplied, we'll take a conservative approach of 64 elements
match constraints {
Some(ref constraints) => {
let mut ignore_min = true;
let mut ignore_max = true;
min = if let Some(ref min) = constraints.min {
if mutator.gen_chance(crate::mutator::CHANCE_TO_IGNORE_MIN_MAX) {
$name::min_value()
} else {
ignore_min = false;
*min
}
} else {
$name::min_value()
};
max = if let Some(ref max) = constraints.max {
if mutator.gen_chance(crate::mutator::CHANCE_TO_IGNORE_MIN_MAX) {
$name::max_value()
} else {
ignore_max = false;
*max
}
} else {
$name::max_value()
};
weight = constraints.weighted;
// these conditions being met should be rare, so bump the chance to 75%
if ignore_min && ignore_max && mutator.gen_chance(0.75) {
return $name::select_dangerous_number(&mut mutator.rng);
}
return mutator.gen_weighted_range(min, max, weight);
}
None => {
if mutator.gen_chance(0.25) {
return $name::select_dangerous_number(&mut mutator.rng);
}
return mutator.rng.gen();
}
}
}