@@ -539,19 +539,23 @@ pub fn do_local_search_with_string(path: &[&str], filepath: &Path, pos: uint,
539
539
// HACK: Make box iterator support iterator trait
540
540
//
541
541
// I can't get the type signature to resolve_name to compile, so instead am boxing it into a trait object and then returning it as an iterator
542
- pub struct BoxIter {
543
- iter : Box < Iterator < Match > >
542
+ pub struct BoxIter < T > {
543
+ iter : Box < Iterator < T > >
544
544
}
545
545
546
- impl Iterator < Match > for BoxIter {
546
+ impl < T > Iterator < T > for BoxIter < T > {
547
547
#[ inline]
548
- fn next ( & mut self ) -> Option < Match > {
548
+ fn next ( & mut self ) -> Option < T > {
549
549
return self . iter . next ( ) ;
550
550
}
551
551
}
552
552
553
+ pub fn wrap_boxed_iter < T > ( boxediter : Box < Iterator < T > > ) -> BoxIter < T > {
554
+ return BoxIter { iter : boxediter } ;
555
+ }
556
+
553
557
pub fn resolve_name ( searchstr : & str , filepath : & Path , pos : uint ,
554
- search_type : SearchType , namespace : Namespace ) -> BoxIter {
558
+ search_type : SearchType , namespace : Namespace ) -> BoxIter < Match > {
555
559
let msrc = racer:: load_file_and_mask_comments ( filepath) ;
556
560
557
561
let s = String :: from_str ( searchstr) ;
@@ -628,18 +632,14 @@ pub fn resolve_name(searchstr: &str, filepath: &Path, pos: uint,
628
632
629
633
630
634
pub fn resolve_path ( path : & [ & str ] , filepath : & Path , pos : uint ,
631
- search_type : SearchType , namespace : Namespace ) -> vec :: MoveItems < Match > {
635
+ search_type : SearchType , namespace : Namespace ) -> BoxIter < Match > {
632
636
debug ! ( "PHIL do_local_search path {} in {}" , path, filepath. as_str( ) ) ;
633
637
634
- let mut out = Vec :: new ( ) ;
635
-
636
638
if path. len ( ) == 1 {
637
639
let searchstr = path[ 0 ] ;
638
- for m in resolve_name ( searchstr, filepath, pos, search_type, namespace) {
639
- out. push ( m) ;
640
- }
641
- return out. move_iter ( ) ;
640
+ return resolve_name ( searchstr, filepath, pos, search_type, namespace) ;
642
641
} else {
642
+ let mut out = Vec :: new ( ) ;
643
643
if path[ 0 ] == "" {
644
644
// match global searches starting with :: - e.g. ::std::blah::...
645
645
for m in do_external_search ( path. slice_from ( 1 ) , filepath, pos, search_type, namespace) {
@@ -688,7 +688,7 @@ pub fn resolve_path(path: &[&str], filepath: &Path, pos: uint,
688
688
}
689
689
} ) ;
690
690
691
- return out. move_iter ( ) ;
691
+ return BoxIter { iter : box out. move_iter ( ) as Box < Iterator < Match > > } ;
692
692
}
693
693
}
694
694
0 commit comments