@@ -82,14 +82,14 @@ A prime generator, using the Trial Division method.
82
82
Create with `let mut pset = TrialDivision::new()`, and then use `pset.iter()` to iterate over all
83
83
primes.
84
84
**/
85
- #[ derive( Default , Clone ) ]
85
+ #[ derive( Clone ) ]
86
86
pub struct TrialDivision {
87
87
lst : Vec < u64 > ,
88
88
}
89
89
90
90
const WHEEL30 : [ u64 ; 8 ] = [ 1 , 7 , 11 , 13 , 17 , 19 , 23 , 29 ] ;
91
91
92
- #[ derive( Default , Copy , Clone ) ]
92
+ #[ derive( Copy , Clone ) ]
93
93
struct Wheel30 {
94
94
base : u64 ,
95
95
ix : usize ,
@@ -107,13 +107,19 @@ impl Wheel30 {
107
107
}
108
108
}
109
109
110
+ impl Default for Wheel30 {
111
+ fn default ( ) -> Self {
112
+ Wheel30 { base : 0 , ix : 1 }
113
+ }
114
+ }
115
+
110
116
/**
111
117
A prime generator, using the Sieve of Eratosthenes method. This is asymptotically more efficient
112
118
than the Trial Division method, but slower earlier on.
113
119
114
120
Create with `let mut pset = Sieve::new()`, and then use `pset.iter()` to iterate over all primes.
115
121
**/
116
- #[ derive( Default , Clone ) ]
122
+ #[ derive( Clone ) ]
117
123
pub struct Sieve {
118
124
primes : Vec < u64 > ,
119
125
wheel : Wheel30 ,
@@ -142,6 +148,12 @@ impl TrialDivision {
142
148
}
143
149
}
144
150
151
+ impl Default for TrialDivision {
152
+ fn default ( ) -> Self {
153
+ Self :: new ( )
154
+ }
155
+ }
156
+
145
157
impl PrimeSetBasics for TrialDivision {
146
158
/// Finds one more prime, and adds it to the list
147
159
fn expand ( & mut self ) {
@@ -170,6 +182,12 @@ impl PrimeSetBasics for TrialDivision {
170
182
}
171
183
}
172
184
185
+ impl Default for Sieve {
186
+ fn default ( ) -> Self {
187
+ Self :: new ( )
188
+ }
189
+ }
190
+
173
191
impl Sieve {
174
192
/// A new prime generator, primed with 2 and 3
175
193
pub fn new ( ) -> Sieve {
0 commit comments