1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
use crate::DefaultMutator;
use crate::Mutator;
#[derive(Default)]
pub struct BoxMutator<M> {
mutator: M,
}
impl<M> BoxMutator<M> {
#[no_coverage]
pub fn new(mutator: M) -> Self {
Self { mutator }
}
}
impl<T: Clone, M: Mutator<T>> Mutator<Box<T>> for BoxMutator<M> {
#[doc(hidden)]
type Cache = M::Cache;
#[doc(hidden)]
type MutationStep = M::MutationStep;
#[doc(hidden)]
type ArbitraryStep = M::ArbitraryStep;
#[doc(hidden)]
type UnmutateToken = M::UnmutateToken;
#[doc(hidden)]
#[no_coverage]
fn default_arbitrary_step(&self) -> Self::ArbitraryStep {
self.mutator.default_arbitrary_step()
}
#[doc(hidden)]
#[no_coverage]
fn validate_value(&self, value: &Box<T>) -> Option<Self::Cache> {
self.mutator.validate_value(value)
}
#[doc(hidden)]
#[no_coverage]
fn default_mutation_step(&self, value: &Box<T>, cache: &Self::Cache) -> Self::MutationStep {
self.mutator.default_mutation_step(value, cache)
}
#[doc(hidden)]
#[no_coverage]
fn max_complexity(&self) -> f64 {
self.mutator.max_complexity()
}
#[doc(hidden)]
#[no_coverage]
fn min_complexity(&self) -> f64 {
self.mutator.min_complexity()
}
#[doc(hidden)]
#[no_coverage]
fn complexity(&self, value: &Box<T>, cache: &Self::Cache) -> f64 {
self.mutator.complexity(value, cache)
}
#[doc(hidden)]
#[no_coverage]
fn ordered_arbitrary(&self, step: &mut Self::ArbitraryStep, max_cplx: f64) -> Option<(Box<T>, f64)> {
if let Some((value, cache)) = self.mutator.ordered_arbitrary(step, max_cplx) {
Some((Box::new(value), cache))
} else {
None
}
}
#[doc(hidden)]
#[no_coverage]
fn random_arbitrary(&self, max_cplx: f64) -> (Box<T>, f64) {
let (value, cache) = self.mutator.random_arbitrary(max_cplx);
(Box::new(value), cache)
}
#[doc(hidden)]
#[no_coverage]
fn ordered_mutate(
&self,
value: &mut Box<T>,
cache: &mut Self::Cache,
step: &mut Self::MutationStep,
max_cplx: f64,
) -> Option<(Self::UnmutateToken, f64)> {
self.mutator.ordered_mutate(value, cache, step, max_cplx)
}
#[doc(hidden)]
#[no_coverage]
fn random_mutate(&self, value: &mut Box<T>, cache: &mut Self::Cache, max_cplx: f64) -> (Self::UnmutateToken, f64) {
self.mutator.random_mutate(value, cache, max_cplx)
}
#[doc(hidden)]
#[no_coverage]
fn unmutate(&self, value: &mut Box<T>, cache: &mut Self::Cache, t: Self::UnmutateToken) {
self.mutator.unmutate(value, cache, t)
}
#[doc(hidden)]
type RecursingPartIndex = M::RecursingPartIndex;
#[doc(hidden)]
#[no_coverage]
fn default_recursing_part_index(&self, value: &Box<T>, cache: &Self::Cache) -> Self::RecursingPartIndex {
self.mutator.default_recursing_part_index(value, cache)
}
#[doc(hidden)]
#[no_coverage]
fn recursing_part<'a, V, N>(
&self,
parent: &N,
value: &'a Box<T>,
index: &mut Self::RecursingPartIndex,
) -> Option<&'a V>
where
V: Clone + 'static,
N: Mutator<V>,
{
self.mutator.recursing_part::<V, N>(parent, value, index)
}
}
impl<T> DefaultMutator for Box<T>
where
T: DefaultMutator,
{
#[doc(hidden)]
type Mutator = BoxMutator<<T as DefaultMutator>::Mutator>;
#[doc(hidden)]
#[no_coverage]
fn default_mutator() -> Self::Mutator {
Self::Mutator::new(T::default_mutator())
}
}