@@ -260,7 +260,9 @@ pub mod reader {
260
260
}
261
261
}
262
262
263
- pub fn docs < ' a > ( d : Doc < ' a > , it : |uint , Doc < ' a > | -> bool ) -> bool {
263
+ pub fn docs < F > ( d : Doc , mut it : F ) -> bool where
264
+ F : FnMut ( uint , Doc ) -> bool ,
265
+ {
264
266
let mut pos = d. start ;
265
267
while pos < d. end {
266
268
let elt_tag = try_or ! ( vuint_at( d. data, pos) , false ) ;
@@ -274,7 +276,9 @@ pub mod reader {
274
276
return true ;
275
277
}
276
278
277
- pub fn tagged_docs < ' a > ( d : Doc < ' a > , tg : uint , it: |Doc < ' a > | -> bool ) -> bool {
279
+ pub fn tagged_docs < F > ( d : Doc , tg : uint , mut it : F ) -> bool where
280
+ F : FnMut ( Doc ) -> bool ,
281
+ {
278
282
let mut pos = d. start ;
279
283
while pos < d. end {
280
284
let elt_tag = try_or ! ( vuint_at( d. data, pos) , false ) ;
@@ -291,7 +295,9 @@ pub mod reader {
291
295
return true ;
292
296
}
293
297
294
- pub fn with_doc_data < ' a , T > ( d : Doc < ' a > , f: |x: & ' a [ u8 ] | -> T ) -> T {
298
+ pub fn with_doc_data < T , F > ( d : Doc , f : F ) -> T where
299
+ F : FnOnce ( & [ u8 ] ) -> T ,
300
+ {
295
301
f ( d. data [ d. start ..d. end ] )
296
302
}
297
303
@@ -399,8 +405,9 @@ pub mod reader {
399
405
Ok ( r as uint )
400
406
}
401
407
402
- pub fn read_opaque < R > ( & mut self ,
403
- op : |& mut Decoder < ' doc > , Doc | -> DecodeResult < R > ) -> DecodeResult < R > {
408
+ pub fn read_opaque < R , F > ( & mut self , op : F ) -> DecodeResult < R > where
409
+ F : FnOnce ( & mut Decoder , Doc ) -> DecodeResult < R > ,
410
+ {
404
411
let doc = try!( self . next_doc ( EsOpaque ) ) ;
405
412
406
413
let ( old_parent, old_pos) = ( self . parent , self . pos ) ;
@@ -761,7 +768,9 @@ pub mod writer {
761
768
Ok ( r)
762
769
}
763
770
764
- pub fn wr_tag ( & mut self , tag_id : uint , blk: || -> EncodeResult ) -> EncodeResult {
771
+ pub fn wr_tag < F > ( & mut self , tag_id : uint , blk : F ) -> EncodeResult where
772
+ F : FnOnce ( ) -> EncodeResult ,
773
+ {
765
774
try!( self . start_tag ( tag_id) ) ;
766
775
try!( blk ( ) ) ;
767
776
self . end_tag ( )
@@ -857,7 +866,9 @@ pub mod writer {
857
866
else { Ok ( ( ) ) }
858
867
}
859
868
860
- pub fn emit_opaque ( & mut self , f: |& mut Encoder < W > | -> EncodeResult ) -> EncodeResult {
869
+ pub fn emit_opaque < F > ( & mut self , f : F ) -> EncodeResult where
870
+ F : FnOnce ( & mut Encoder < W > ) -> EncodeResult ,
871
+ {
861
872
try!( self . start_tag ( EsOpaque as uint ) ) ;
862
873
try!( f ( self ) ) ;
863
874
self . end_tag ( )
0 commit comments