@@ -282,6 +282,17 @@ pub struct VecPerParamSpace<T> {
282
282
content : Vec < T > ,
283
283
}
284
284
285
+ /**
286
+ * The `split` function converts one `VecPerParamSpace` into this
287
+ * `SeparateVecsPerParamSpace` structure.
288
+ */
289
+ pub struct SeparateVecsPerParamSpace < T > {
290
+ pub types : Vec < T > ,
291
+ pub selfs : Vec < T > ,
292
+ pub assocs : Vec < T > ,
293
+ pub fns : Vec < T > ,
294
+ }
295
+
285
296
impl < T : fmt:: Show > fmt:: Show for VecPerParamSpace < T > {
286
297
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
287
298
try!( write ! ( fmt, "VecPerParamSpace {{" ) ) ;
@@ -464,24 +475,30 @@ impl<T> VecPerParamSpace<T> {
464
475
}
465
476
466
477
pub fn map_move < U > ( self , pred: |T | -> U ) -> VecPerParamSpace < U > {
467
- let ( t, s, a, f) = self . split ( ) ;
478
+ let SeparateVecsPerParamSpace {
479
+ types : t,
480
+ selfs : s,
481
+ assocs : a,
482
+ fns : f
483
+ } = self . split ( ) ;
484
+
468
485
VecPerParamSpace :: new ( t. into_iter ( ) . map ( |p| pred ( p) ) . collect ( ) ,
469
486
s. into_iter ( ) . map ( |p| pred ( p) ) . collect ( ) ,
470
487
a. into_iter ( ) . map ( |p| pred ( p) ) . collect ( ) ,
471
488
f. into_iter ( ) . map ( |p| pred ( p) ) . collect ( ) )
472
489
}
473
490
474
- pub fn split ( self ) -> ( Vec < T > , Vec < T > , Vec < T > , Vec < T > ) {
491
+ pub fn split ( self ) -> SeparateVecsPerParamSpace < T > {
475
492
let VecPerParamSpace { type_limit, self_limit, assoc_limit, content } = self ;
476
493
477
494
let mut content_iter = content. into_iter ( ) ;
478
495
479
- let types = content_iter . by_ref ( ) . take ( type_limit ) . collect ( ) ;
480
- let selfs = content_iter. by_ref ( ) . take ( self_limit - type_limit) . collect ( ) ;
481
- let assocs = content_iter. by_ref ( ) . take ( assoc_limit - self_limit ) . collect ( ) ;
482
- let fns = content_iter. collect ( ) ;
483
-
484
- ( types , selfs , assocs , fns )
496
+ SeparateVecsPerParamSpace {
497
+ types : content_iter. by_ref ( ) . take ( type_limit) . collect ( ) ,
498
+ selfs : content_iter. by_ref ( ) . take ( self_limit - type_limit ) . collect ( ) ,
499
+ assocs : content_iter. by_ref ( ) . take ( assoc_limit - self_limit ) . collect ( ) ,
500
+ fns : content_iter . collect ( )
501
+ }
485
502
}
486
503
487
504
pub fn with_vec ( mut self , space : ParamSpace , vec : Vec < T > )
0 commit comments