@@ -17,7 +17,7 @@ impl Arbitrary for Create {
1717 }
1818}
1919
20- impl ArbitraryFrom < Vec < Table > > for Select {
20+ impl ArbitraryFrom < & Vec < Table > > for Select {
2121 fn arbitrary_from < R : Rng > ( rng : & mut R , tables : & Vec < Table > ) -> Self {
2222 let table = pick ( tables, rng) ;
2323 Self {
@@ -27,7 +27,7 @@ impl ArbitraryFrom<Vec<Table>> for Select {
2727 }
2828}
2929
30- impl ArbitraryFrom < Vec < & Table > > for Select {
30+ impl ArbitraryFrom < & Vec < & Table > > for Select {
3131 fn arbitrary_from < R : Rng > ( rng : & mut R , tables : & Vec < & Table > ) -> Self {
3232 let table = pick ( tables, rng) ;
3333 Self {
@@ -37,7 +37,7 @@ impl ArbitraryFrom<Vec<&Table>> for Select {
3737 }
3838}
3939
40- impl ArbitraryFrom < Table > for Insert {
40+ impl ArbitraryFrom < & Table > for Insert {
4141 fn arbitrary_from < R : Rng > ( rng : & mut R , table : & Table ) -> Self {
4242 let num_rows = rng. gen_range ( 1 ..10 ) ;
4343 let values: Vec < Vec < Value > > = ( 0 ..num_rows)
@@ -56,7 +56,7 @@ impl ArbitraryFrom<Table> for Insert {
5656 }
5757}
5858
59- impl ArbitraryFrom < Table > for Delete {
59+ impl ArbitraryFrom < & Table > for Delete {
6060 fn arbitrary_from < R : Rng > ( rng : & mut R , table : & Table ) -> Self {
6161 Self {
6262 table : table. name . clone ( ) ,
@@ -65,7 +65,7 @@ impl ArbitraryFrom<Table> for Delete {
6565 }
6666}
6767
68- impl ArbitraryFrom < Table > for Query {
68+ impl ArbitraryFrom < & Table > for Query {
6969 fn arbitrary_from < R : Rng > ( rng : & mut R , table : & Table ) -> Self {
7070 frequency (
7171 vec ! [
@@ -89,7 +89,7 @@ impl ArbitraryFrom<Table> for Query {
8989}
9090
9191impl ArbitraryFrom < ( & Table , & Remaining ) > for Query {
92- fn arbitrary_from < R : Rng > ( rng : & mut R , ( table, remaining) : & ( & Table , & Remaining ) ) -> Self {
92+ fn arbitrary_from < R : Rng > ( rng : & mut R , ( table, remaining) : ( & Table , & Remaining ) ) -> Self {
9393 frequency (
9494 vec ! [
9595 (
@@ -98,7 +98,7 @@ impl ArbitraryFrom<(&Table, &Remaining)> for Query {
9898 ) ,
9999 (
100100 remaining. read,
101- Box :: new( |rng| Self :: Select ( Select :: arbitrary_from( rng, & vec![ * table] ) ) ) ,
101+ Box :: new( |rng| Self :: Select ( Select :: arbitrary_from( rng, & vec![ table] ) ) ) ,
102102 ) ,
103103 (
104104 remaining. write,
@@ -118,7 +118,7 @@ struct CompoundPredicate(Predicate);
118118struct SimplePredicate ( Predicate ) ;
119119
120120impl ArbitraryFrom < ( & Table , bool ) > for SimplePredicate {
121- fn arbitrary_from < R : Rng > ( rng : & mut R , ( table, predicate_value) : & ( & Table , bool ) ) -> Self {
121+ fn arbitrary_from < R : Rng > ( rng : & mut R , ( table, predicate_value) : ( & Table , bool ) ) -> Self {
122122 // Pick a random column
123123 let column_index = rng. gen_range ( 0 ..table. columns . len ( ) ) ;
124124 let column = & table. columns [ column_index] ;
@@ -182,15 +182,15 @@ impl ArbitraryFrom<(&Table, bool)> for SimplePredicate {
182182}
183183
184184impl ArbitraryFrom < ( & Table , bool ) > for CompoundPredicate {
185- fn arbitrary_from < R : Rng > ( rng : & mut R , ( table, predicate_value) : & ( & Table , bool ) ) -> Self {
185+ fn arbitrary_from < R : Rng > ( rng : & mut R , ( table, predicate_value) : ( & Table , bool ) ) -> Self {
186186 // Decide if you want to create an AND or an OR
187187 Self ( if rng. gen_bool ( 0.7 ) {
188188 // An AND for true requires each of its children to be true
189189 // An AND for false requires at least one of its children to be false
190- if * predicate_value {
190+ if predicate_value {
191191 Predicate :: And (
192192 ( 0 ..rng. gen_range ( 0 ..=3 ) )
193- . map ( |_| SimplePredicate :: arbitrary_from ( rng, & ( * table, true ) ) . 0 )
193+ . map ( |_| SimplePredicate :: arbitrary_from ( rng, ( table, true ) ) . 0 )
194194 . collect ( ) ,
195195 )
196196 } else {
@@ -209,14 +209,14 @@ impl ArbitraryFrom<(&Table, bool)> for CompoundPredicate {
209209 Predicate :: And (
210210 booleans
211211 . iter ( )
212- . map ( |b| SimplePredicate :: arbitrary_from ( rng, & ( * table, * b) ) . 0 )
212+ . map ( |b| SimplePredicate :: arbitrary_from ( rng, ( table, * b) ) . 0 )
213213 . collect ( ) ,
214214 )
215215 }
216216 } else {
217217 // An OR for true requires at least one of its children to be true
218218 // An OR for false requires each of its children to be false
219- if * predicate_value {
219+ if predicate_value {
220220 // Create a vector of random booleans
221221 let mut booleans = ( 0 ..rng. gen_range ( 0 ..=3 ) )
222222 . map ( |_| rng. gen_bool ( 0.5 ) )
@@ -230,42 +230,42 @@ impl ArbitraryFrom<(&Table, bool)> for CompoundPredicate {
230230 Predicate :: Or (
231231 booleans
232232 . iter ( )
233- . map ( |b| SimplePredicate :: arbitrary_from ( rng, & ( * table, * b) ) . 0 )
233+ . map ( |b| SimplePredicate :: arbitrary_from ( rng, ( table, * b) ) . 0 )
234234 . collect ( ) ,
235235 )
236236 } else {
237237 Predicate :: Or (
238238 ( 0 ..rng. gen_range ( 0 ..=3 ) )
239- . map ( |_| SimplePredicate :: arbitrary_from ( rng, & ( * table, false ) ) . 0 )
239+ . map ( |_| SimplePredicate :: arbitrary_from ( rng, ( table, false ) ) . 0 )
240240 . collect ( ) ,
241241 )
242242 }
243243 } )
244244 }
245245}
246246
247- impl ArbitraryFrom < Table > for Predicate {
247+ impl ArbitraryFrom < & Table > for Predicate {
248248 fn arbitrary_from < R : Rng > ( rng : & mut R , table : & Table ) -> Self {
249249 let predicate_value = rng. gen_bool ( 0.5 ) ;
250- CompoundPredicate :: arbitrary_from ( rng, & ( table, predicate_value) ) . 0
250+ CompoundPredicate :: arbitrary_from ( rng, ( table, predicate_value) ) . 0
251251 }
252252}
253253
254254impl ArbitraryFrom < ( & str , & Value ) > for Predicate {
255- fn arbitrary_from < R : Rng > ( rng : & mut R , ( column_name, value) : & ( & str , & Value ) ) -> Self {
255+ fn arbitrary_from < R : Rng > ( rng : & mut R , ( column_name, value) : ( & str , & Value ) ) -> Self {
256256 one_of (
257257 vec ! [
258258 Box :: new( |_| Predicate :: Eq ( column_name. to_string( ) , ( * value) . clone( ) ) ) ,
259259 Box :: new( |rng| {
260260 Self :: Gt (
261261 column_name. to_string( ) ,
262- GTValue :: arbitrary_from( rng, * value) . 0 ,
262+ GTValue :: arbitrary_from( rng, value) . 0 ,
263263 )
264264 } ) ,
265265 Box :: new( |rng| {
266266 Self :: Lt (
267267 column_name. to_string( ) ,
268- LTValue :: arbitrary_from( rng, * value) . 0 ,
268+ LTValue :: arbitrary_from( rng, value) . 0 ,
269269 )
270270 } ) ,
271271 ] ,
@@ -275,7 +275,7 @@ impl ArbitraryFrom<(&str, &Value)> for Predicate {
275275}
276276
277277/// Produces a predicate that is true for the provided row in the given table
278- fn produce_true_predicate < R : Rng > ( rng : & mut R , ( t, row) : & ( & Table , & Vec < Value > ) ) -> Predicate {
278+ fn produce_true_predicate < R : Rng > ( rng : & mut R , ( t, row) : ( & Table , & Vec < Value > ) ) -> Predicate {
279279 // Pick a column
280280 let column_index = rng. gen_range ( 0 ..t. columns . len ( ) ) ;
281281 let column = & t. columns [ column_index] ;
@@ -304,7 +304,7 @@ fn produce_true_predicate<R: Rng>(rng: &mut R, (t, row): &(&Table, &Vec<Value>))
304304}
305305
306306/// Produces a predicate that is false for the provided row in the given table
307- fn produce_false_predicate < R : Rng > ( rng : & mut R , ( t, row) : & ( & Table , & Vec < Value > ) ) -> Predicate {
307+ fn produce_false_predicate < R : Rng > ( rng : & mut R , ( t, row) : ( & Table , & Vec < Value > ) ) -> Predicate {
308308 // Pick a column
309309 let column_index = rng. gen_range ( 0 ..t. columns . len ( ) ) ;
310310 let column = & t. columns [ column_index] ;
@@ -333,18 +333,18 @@ fn produce_false_predicate<R: Rng>(rng: &mut R, (t, row): &(&Table, &Vec<Value>)
333333}
334334
335335impl ArbitraryFrom < ( & Table , & Vec < Value > ) > for Predicate {
336- fn arbitrary_from < R : Rng > ( rng : & mut R , ( t, row) : & ( & Table , & Vec < Value > ) ) -> Self {
336+ fn arbitrary_from < R : Rng > ( rng : & mut R , ( t, row) : ( & Table , & Vec < Value > ) ) -> Self {
337337 // We want to produce a predicate that is true for the row
338338 // We can do this by creating several predicates that
339339 // are true, some that are false, combiend them in ways that correspond to the creation of a true predicate
340340
341341 // Produce some true and false predicates
342342 let mut true_predicates = ( 1 ..=rng. gen_range ( 1 ..=4 ) )
343- . map ( |_| produce_true_predicate ( rng, & ( * t, row) ) )
343+ . map ( |_| produce_true_predicate ( rng, ( t, row) ) )
344344 . collect :: < Vec < _ > > ( ) ;
345345
346346 let false_predicates = ( 0 ..=rng. gen_range ( 0 ..=3 ) )
347- . map ( |_| produce_false_predicate ( rng, & ( * t, row) ) )
347+ . map ( |_| produce_false_predicate ( rng, ( t, row) ) )
348348 . collect :: < Vec < _ > > ( ) ;
349349
350350 // Start building a top level predicate from a true predicate
0 commit comments