File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ pub struct Filter {
116
116
pub struct Builder {
117
117
directives : Vec < Directive > ,
118
118
filter : Option < inner:: Filter > ,
119
+ built : bool ,
119
120
}
120
121
121
122
#[ derive( Debug ) ]
@@ -183,6 +184,7 @@ impl Builder {
183
184
Builder {
184
185
directives : Vec :: new ( ) ,
185
186
filter : None ,
187
+ built : false ,
186
188
}
187
189
}
188
190
@@ -239,6 +241,9 @@ impl Builder {
239
241
240
242
/// Build a log filter.
241
243
pub fn build ( & mut self ) -> Filter {
244
+ assert ! ( !self . built, "attempt to re-use consumed builder" ) ;
245
+ self . built = true ;
246
+
242
247
if self . directives . is_empty ( ) {
243
248
// Adds the default filter if none exist
244
249
self . directives . push ( Directive {
@@ -279,10 +284,16 @@ impl fmt::Debug for Filter {
279
284
280
285
impl fmt:: Debug for Builder {
281
286
fn fmt ( & self , f : & mut fmt:: Formatter ) ->fmt:: Result {
282
- f. debug_struct ( "Filter" )
287
+ if self . built {
288
+ f. debug_struct ( "Filter" )
289
+ . field ( "built" , & true )
290
+ . finish ( )
291
+ } else {
292
+ f. debug_struct ( "Filter" )
283
293
. field ( "filter" , & self . filter )
284
294
. field ( "directives" , & self . directives )
285
295
. finish ( )
296
+ }
286
297
}
287
298
}
288
299
You can’t perform that action at this time.
0 commit comments